Return correct errors and set loginInProgress to false
Merge pull request #1138 from Nevtep/login-fix

Return correct errors and set loginInProgress to false   Addresses #1139