IOS-2161 client certificate option is only shown if there is a client certificate IOS-2161
authorXavier Algarra <xavier@pep-project.org>
Wed, 11 Mar 2020 18:01:58 +0100
branchIOS-2161
changeset 12209640fc75f9183
parent 12208 8effeac956eb
child 12257 66cc71268af7
IOS-2161 client certificate option is only shown if there is a client certificate
pEpForiOS/UI/Login/ViewModel/AccountTypeSelectorViewModel.swift
     1.1 --- a/pEpForiOS/UI/Login/ViewModel/AccountTypeSelectorViewModel.swift	Wed Mar 11 17:46:22 2020 +0100
     1.2 +++ b/pEpForiOS/UI/Login/ViewModel/AccountTypeSelectorViewModel.swift	Wed Mar 11 18:01:58 2020 +0100
     1.3 @@ -23,12 +23,18 @@
     1.4      public weak var delegate: AccountTypeSelectorViewModelDelegate?
     1.5  
     1.6      /// list of providers to show
     1.7 -    private let accountTypes: [VerifiableAccount.AccountType] = [.gmail, .clientCertificate, .other]
     1.8 +    private var accountTypes: [VerifiableAccount.AccountType]
     1.9  
    1.10      init(verifiableAccount: VerifiableAccountProtocol? = nil,
    1.11           clientCertificateUtil: ClientCertificateUtilProtocol? = nil) {
    1.12          self.verifiableAccount = verifiableAccount ?? VerifiableAccount()
    1.13          self.clientCertificateUtil = clientCertificateUtil ?? ClientCertificateUtil()
    1.14 +        accountTypes = [VerifiableAccount.AccountType]()
    1.15 +        accountTypes.append(.gmail)
    1.16 +        if self.clientCertificateUtil.listCertificates(session: nil).count > 0 {
    1.17 +            accountTypes.append(.clientCertificate)
    1.18 +        }
    1.19 +        accountTypes.append(.other)
    1.20      }
    1.21  
    1.22      var count: Int {