auth/auth: add refresh error 2000 hotfix

References: https://github.com/emersion/hydroxide/issues/70
This commit is contained in:
Dmitry Valter 2019-10-10 01:44:01 +03:00 committed by Simon Ser
parent 40cadc850f
commit d5a7cf4e0a
1 changed files with 2 additions and 1 deletions

View File

@ -112,7 +112,8 @@ func EncryptAndSave(auth *CachedAuth, username string, secretKey *[32]byte) erro
func authenticate(c *protonmail.Client, cachedAuth *CachedAuth, username string) (openpgp.EntityList, error) { func authenticate(c *protonmail.Client, cachedAuth *CachedAuth, username string) (openpgp.EntityList, error) {
auth, err := c.AuthRefresh(&cachedAuth.Auth) auth, err := c.AuthRefresh(&cachedAuth.Auth)
if apiErr, ok := err.(*protonmail.APIError); ok && apiErr.Code == 10013 { // TODO: error code 2000/2001 'invalid input' happens since 09.2019
if apiErr, ok := err.(*protonmail.APIError); ok && (apiErr.Code == 10013 || apiErr.Code == 2000 || apiErr.Code == 2001) {
// Invalid refresh token, re-authenticate // Invalid refresh token, re-authenticate
authInfo, err := c.AuthInfo(username) authInfo, err := c.AuthInfo(username)
if err != nil { if err != nil {