auth: fix re-auth 2FA error message not showing up

There was a confusing error message instead:

    [403] Access token does not have sufficient scope

Which just meant the access token was used without completing 2FA.
This commit is contained in:
Simon Ser 2021-11-23 11:25:27 +01:00
parent 9aeff319ba
commit fd518b533c
1 changed files with 4 additions and 4 deletions

View File

@ -119,14 +119,14 @@ func authenticate(c *protonmail.Client, cachedAuth *CachedAuth, username string)
return nil, fmt.Errorf("cannot re-authenticate: failed to get auth info: %v", err) return nil, fmt.Errorf("cannot re-authenticate: failed to get auth info: %v", err)
} }
if cachedAuth.TwoFactor.Enabled == 1 {
return nil, fmt.Errorf("cannot re-authenticate: two factor authentication enabled, please login manually")
}
auth, err = c.Auth(username, cachedAuth.LoginPassword, authInfo) auth, err = c.Auth(username, cachedAuth.LoginPassword, authInfo)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot re-authenticate: %v", err) return nil, fmt.Errorf("cannot re-authenticate: %v", err)
} }
if auth.TwoFactor.Enabled == 1 {
return nil, fmt.Errorf("cannot re-authenticate: two factor authentication enabled, please login again manually")
}
} else if err != nil { } else if err != nil {
return nil, err return nil, err
} }