Fix several bugs regarding login verification

Sorry about the oversight on the previous commit. This should fix some bugs in authentication.