4 ms·
Unless you have spaces in your password
by enobrev 8y ago
Unless you have spaces in your password
- lucb1e 8y agoThen just split on the first space (I do that a lot with text files that I parse, like `for line in file: date, hours_worked, comment = line.strip().split(' ', 2)`. The real issue starts when you have spaces in your username. We should just use some non-printable, like, I don't know... tab?
- tzs 8y agoIt's only a problem if you have leading spaces in your password. If you want the option of single field login you would have to avoid that. I suppose an interior space in a password also raises the possibility of accidentally logging in as someone else. Suppose your password is "foo bar.spam", and you try to login using the normal two field approach, so you put your username in the username field and "foo bar.spam" is the password field, but somehow botch filling out the username field so it is blank. The system will try the alternative interpretation, that you want to login as user "foo" with password "bar.spam". If there happens to be someone with "foo" as a username who happens to have "bar.spam" as a password, you will end up logged in as them! This could be addressed by requiring some special value in the username field to signal you want to use the one field option. Say, "a" as the username means look for combined username/password in the password field. It's slightly more work for the user as they do have to enter something in username now, but still only needs one copy/paste which is the main point.