Bugfix

Fixed a missing $db in the doLogin function that was causing a whole
pile of errors.
Bugfix

Fixed a missing $badge for all of the different conditional paths.