Fixed bugs in login mechanism and added messages

Added different messages for different mistakes, such as failing to log
in, when a log in is failed or successful, trying to get a token without
a username, and getting a token with an invalid username.