GODT-1524: Logout issues with macOS.

This commit is contained in:
Jakub
2022-03-14 16:37:42 +01:00
parent 2d5ea669a5
commit 6671dd38ea
26 changed files with 411 additions and 135 deletions

View File

@ -223,7 +223,7 @@ func (u *User) UpdateSpace(apiUser *pmapi.User) {
// values from client.CurrentUser()
if apiUser == nil {
var err error
apiUser, err = u.client.GetUser(pmapi.ContextWithoutRetry(context.Background()))
apiUser, err = u.GetClient().GetUser(pmapi.ContextWithoutRetry(context.Background()))
if err != nil {
u.log.WithError(err).Warning("Cannot update user space")
return
@ -280,16 +280,21 @@ func (u *User) unlockIfNecessary() error {
return nil
}
switch errors.Cause(err) {
case pmapi.ErrNoConnection, pmapi.ErrUpgradeApplication:
u.log.WithError(err).Warn("Could not unlock user")
return nil
if pmapi.IsFailedAuth(err) || pmapi.IsFailedUnlock(err) {
if logoutErr := u.logout(); logoutErr != nil {
u.log.WithError(logoutErr).Warn("Could not logout user")
}
return errors.Wrap(err, "failed to unlock user")
}
if logoutErr := u.logout(); logoutErr != nil {
u.log.WithError(logoutErr).Warn("Could not logout user")
switch errors.Cause(err) {
case pmapi.ErrNoConnection, pmapi.ErrUpgradeApplication:
u.log.WithError(err).Warn("Skipping unlock for known reason")
default:
u.log.WithError(err).Error("Unknown unlock issue")
}
return errors.Wrap(err, "failed to unlock user")
return nil
}
// IsCombinedAddressMode returns whether user is set in combined or split mode.