IOS-1542 When OAUTH2, pass it on to verifier. IOS-1542
authorDirk Zimmermann <dz@pep.security>
Thu, 25 Apr 2019 16:25:40 +0200
branchIOS-1542
changeset 8376f517a983ae7c
parent 8375 81ef9257d9b5
child 8377 0ed9a236fa32
IOS-1542 When OAUTH2, pass it on to verifier.
pEpForiOS/UI/Settings/Setting/AccountSettings/ViewModel/AccountSettingsViewModel.swift
     1.1 --- a/pEpForiOS/UI/Settings/Setting/AccountSettings/ViewModel/AccountSettingsViewModel.swift	Thu Apr 25 16:25:40 2019 +0200
     1.2 +++ b/pEpForiOS/UI/Settings/Setting/AccountSettings/ViewModel/AccountSettingsViewModel.swift	Thu Apr 25 16:25:40 2019 +0200
     1.3 @@ -109,17 +109,23 @@
     1.4          theVerifier.address = email
     1.5          theVerifier.userName = name
     1.6  
     1.7 -        theVerifier.password = originalPassword
     1.8 -        if password != nil {
     1.9 -            theVerifier.password = password
    1.10 -        }
    1.11 -
    1.12          if loginName != email {
    1.13              theVerifier.loginName = loginName
    1.14          }
    1.15  
    1.16          if isOAuth2 {
    1.17 -            // TODO: Set correct auth method, etc.
    1.18 +            if self.accessToken == nil {
    1.19 +                Logger.frontendLogger.errorAndCrash("Have to do OAUTH2, but lacking current token")
    1.20 +            }
    1.21 +            theVerifier.authMethod = .saslXoauth2
    1.22 +            theVerifier.accessToken = accessToken
    1.23 +            // OAUTH2 trumps any password
    1.24 +            theVerifier.password = nil
    1.25 +        } else {
    1.26 +            theVerifier.password = originalPassword
    1.27 +            if password != nil {
    1.28 +                theVerifier.password = password
    1.29 +            }
    1.30          }
    1.31  
    1.32          // IMAP