IOS-1542 Try do deduce original account password. IOS-1542
authorDirk Zimmermann <dz@pep.security>
Thu, 25 Apr 2019 16:25:40 +0200
branchIOS-1542
changeset 83740bfb3112a735
parent 8373 ecdd11870f06
child 8375 81ef9257d9b5
IOS-1542 Try do deduce original account password.
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 @@ -53,6 +53,7 @@
     1.4          self.name = account.user.userName ?? ""
     1.5  
     1.6          if let server = account.imapServer {
     1.7 +            self.originalPassword = server.credentials.password
     1.8              self.imapServer = ServerViewModel(
     1.9                  address: server.address,
    1.10                  port: "\(server.port)",
    1.11 @@ -62,6 +63,7 @@
    1.12          }
    1.13  
    1.14          if let server = account.smtpServer {
    1.15 +            self.originalPassword = self.originalPassword ?? server.credentials.password
    1.16              self.smtpServer = ServerViewModel(
    1.17                  address: server.address,
    1.18                  port: "\(server.port)",
    1.19 @@ -88,6 +90,8 @@
    1.20      /// and also the implementation of the verification.
    1.21      private var verifiableAccount: VerifiableAccountProtocol?
    1.22  
    1.23 +    private var originalPassword: String?
    1.24 +
    1.25      // Currently we assume imap and smtp servers exist already (update).
    1.26      // If we run into problems here modify to updateOrCreate.
    1.27      func update(loginName: String, name: String, password: String? = nil, imap: ServerViewModel,
    1.28 @@ -98,8 +102,10 @@
    1.29          theVerifier.address = email
    1.30          theVerifier.userName = name
    1.31  
    1.32 -        // TODO: How to handle if the password got changed or not?
    1.33 -        theVerifier.password = password
    1.34 +        theVerifier.password = originalPassword
    1.35 +        if password != nil {
    1.36 +            theVerifier.password = password
    1.37 +        }
    1.38  
    1.39          if loginName != email {
    1.40              theVerifier.loginName = loginName