Fixed login on upgrade not working on first try.

This resolves issue #447

Signed-off-by: SleePy