summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-04-01 17:13:23 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-04-01 17:19:41 +0200
commit7ede086a82b97a13c669930297be3c17e1982923 (patch)
tree60449ae98748668d6cfc063d252000cf3584f3c2
parent5fecd6dd09d2a62fcb46abaa242b1d89a3acf28c (diff)
downloadmullvadvpn-7ede086a82b97a13c669930297be3c17e1982923.tar.xz
mullvadvpn-7ede086a82b97a13c669930297be3c17e1982923.zip
Update login status messages when logging in with the new account
-rw-r--r--ios/MullvadVPN/LoginState.swift8
-rw-r--r--ios/MullvadVPN/LoginViewController.swift30
2 files changed, 26 insertions, 12 deletions
diff --git a/ios/MullvadVPN/LoginState.swift b/ios/MullvadVPN/LoginState.swift
index 2b107b6f27..a28fefd39b 100644
--- a/ios/MullvadVPN/LoginState.swift
+++ b/ios/MullvadVPN/LoginState.swift
@@ -8,9 +8,13 @@
import Foundation
+enum AuthenticationMethod {
+ case existingAccount, newAccount
+}
+
enum LoginState {
case `default`
- case authenticating
+ case authenticating(AuthenticationMethod)
case failure(AccountError)
- case success
+ case success(AuthenticationMethod)
}
diff --git a/ios/MullvadVPN/LoginViewController.swift b/ios/MullvadVPN/LoginViewController.swift
index 1c97b1f8f6..3de2edba06 100644
--- a/ios/MullvadVPN/LoginViewController.swift
+++ b/ios/MullvadVPN/LoginViewController.swift
@@ -151,14 +151,14 @@ class LoginViewController: UIViewController, UITextFieldDelegate, RootContainmen
@IBAction func doLogin() {
let accountToken = accountTextField.text ?? ""
- beginLogin()
+ beginLogin(method: .existingAccount)
loginSubscriber = Account.shared.login(with: accountToken)
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { (completionResult) in
switch completionResult {
case .finished:
- self.endLogin(.success)
+ self.endLogin(.success(.existingAccount))
case .failure(let error):
self.endLogin(.failure(error))
}
@@ -166,7 +166,7 @@ class LoginViewController: UIViewController, UITextFieldDelegate, RootContainmen
}
@IBAction func createNewAccount() {
- beginLogin()
+ beginLogin(method: .newAccount)
accountTextField.text = ""
@@ -175,7 +175,7 @@ class LoginViewController: UIViewController, UITextFieldDelegate, RootContainmen
.sink(receiveCompletion: { (completionResult) in
switch completionResult {
case .finished:
- self.endLogin(.success)
+ self.endLogin(.success(.newAccount))
case .failure(let error):
self.endLogin(.failure(error))
}
@@ -236,8 +236,8 @@ class LoginViewController: UIViewController, UITextFieldDelegate, RootContainmen
}
}
- private func beginLogin() {
- loginState = .authenticating
+ private func beginLogin(method: AuthenticationMethod) {
+ loginState = .authenticating(method)
view.endEditing(true)
}
@@ -302,14 +302,24 @@ private extension LoginState {
case .default:
return NSLocalizedString("Enter your account number", comment: "")
- case .authenticating:
- return NSLocalizedString("Checking account number", comment: "")
+ case .authenticating(let method):
+ switch method {
+ case .existingAccount:
+ return NSLocalizedString("Checking account number", comment: "")
+ case .newAccount:
+ return NSLocalizedString("Creating new account", comment: "")
+ }
case .failure(let error):
return error.failureReason ?? ""
- case .success:
- return NSLocalizedString("Correct account number", comment: "")
+ case .success(let method):
+ switch method {
+ case .existingAccount:
+ return NSLocalizedString("Correct account number", comment: "")
+ case .newAccount:
+ return NSLocalizedString("Account created", comment: "")
+ }
}
}
}