IOS-1542 Handle incoming parameters for OAUTH2 accounts. IOS-1542
authorDirk Zimmermann <dz@pep.security>
Thu, 25 Apr 2019 16:25:40 +0200
branchIOS-1542
changeset 837581ef9257d9b5
parent 8374 0bfb3112a735
child 8376 f517a983ae7c
IOS-1542 Handle incoming parameters for OAUTH2 accounts.
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 @@ -90,8 +90,15 @@
     1.4      /// and also the implementation of the verification.
     1.5      private var verifiableAccount: VerifiableAccountProtocol?
     1.6  
     1.7 +    /// If the credentials have either an IMAP or SMTP password,
     1.8 +    /// it gets stored here.
     1.9      private var originalPassword: String?
    1.10  
    1.11 +    /// If there was OAUTH2 for this account, here is a current token.
    1.12 +    /// This trumps both the `originalPassword` and a password given by the user
    1.13 +    /// via the UI.
    1.14 +    private var accessToken: OAuth2AccessTokenProtocol?
    1.15 +
    1.16      // Currently we assume imap and smtp servers exist already (update).
    1.17      // If we run into problems here modify to updateOrCreate.
    1.18      func update(loginName: String, name: String, password: String? = nil, imap: ServerViewModel,
    1.19 @@ -181,16 +188,7 @@
    1.20      }
    1.21  
    1.22      func updateToken(accessToken: OAuth2AccessTokenProtocol) {
    1.23 -        // TODO: What to do here? When does this get called?
    1.24 -        /*
    1.25 -        guard let imapServer = account.imapServer,
    1.26 -            let smtpServer = account.smtpServer else {
    1.27 -                return
    1.28 -        }
    1.29 -        let password = accessToken.persistBase64Encoded()
    1.30 -        imapServer.credentials.password = password
    1.31 -        smtpServer.credentials.password = password
    1.32 -         */
    1.33 +        self.accessToken = accessToken
    1.34      }
    1.35  }
    1.36