mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
More 2FA improvements
This commit is contained in:
parent
5266955059
commit
66e562d6c5
@ -568,13 +568,9 @@ final class SecureIdAuthController: ViewController {
|
|||||||
if let password = password {
|
if let password = password {
|
||||||
strongSelf.checkPassword(password: password, inBackground: true, completion: { [weak controller] in
|
strongSelf.checkPassword(password: password, inBackground: true, completion: { [weak controller] in
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
if let strongSelf = self {
|
|
||||||
strongSelf.present(OverlayStatusController(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, type: .genericSuccess(strongSelf.presentationData.strings.TwoStepAuth_EnabledSuccess)), in: .window(.root))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else if shouldDismiss {
|
} else if shouldDismiss {
|
||||||
controller.dismiss()
|
controller.dismiss()
|
||||||
strongSelf.present(OverlayStatusController(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, type: .genericSuccess(strongSelf.presentationData.strings.TwoStepAuth_EnabledSuccess)), in: .window(.root))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -29,6 +29,7 @@ final class SetupTwoStepVerificationContentNode: ASDisplayNode, UITextFieldDeleg
|
|||||||
private let rightActionButton: HighlightableButtonNode
|
private let rightActionButton: HighlightableButtonNode
|
||||||
|
|
||||||
private var isEnabled = true
|
private var isEnabled = true
|
||||||
|
private var clearOnce: Bool = false
|
||||||
|
|
||||||
init(theme: PresentationTheme, kind: SetupTwoStepVerificationStateKind, title: String, subtitle: String, inputType: SetupTwoStepVerificationInputType, placeholder: String, text: String, isPassword: Bool, textUpdated: @escaping (String) -> Void, returnPressed: @escaping () -> Void, leftAction: SetupTwoStepVerificationContentAction?, rightAction: SetupTwoStepVerificationContentAction?) {
|
init(theme: PresentationTheme, kind: SetupTwoStepVerificationStateKind, title: String, subtitle: String, inputType: SetupTwoStepVerificationInputType, placeholder: String, text: String, isPassword: Bool, textUpdated: @escaping (String) -> Void, returnPressed: @escaping () -> Void, leftAction: SetupTwoStepVerificationContentAction?, rightAction: SetupTwoStepVerificationContentAction?) {
|
||||||
self.leftAction = leftAction
|
self.leftAction = leftAction
|
||||||
@ -153,10 +154,25 @@ final class SetupTwoStepVerificationContentNode: ASDisplayNode, UITextFieldDeleg
|
|||||||
self.inputNode.textField.becomeFirstResponder()
|
self.inputNode.textField.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dataEntryError() {
|
||||||
|
self.clearOnce = true
|
||||||
|
}
|
||||||
|
|
||||||
@objc private func inputNodeTextChanged(_ textField: UITextField) {
|
@objc private func inputNodeTextChanged(_ textField: UITextField) {
|
||||||
self.textUpdated(textField.text ?? "")
|
self.textUpdated(textField.text ?? "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||||
|
if self.clearOnce {
|
||||||
|
self.clearOnce = false
|
||||||
|
if range.length > string.count {
|
||||||
|
textField.text = ""
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||||
self.returnPressed()
|
self.returnPressed()
|
||||||
return false
|
return false
|
||||||
|
@ -32,7 +32,7 @@ private enum EnterEmailState: Equatable {
|
|||||||
|
|
||||||
private enum ConfirmEmailState: Equatable {
|
private enum ConfirmEmailState: Equatable {
|
||||||
case create(password: String, hint: String, email: String)
|
case create(password: String, hint: String, email: String)
|
||||||
case add(password: String, hasSecureValues: Bool, email: String)
|
case add(password: String, hadRecoveryEmail: Bool, hasSecureValues: Bool, email: String)
|
||||||
case confirm(password: String?, hasSecureValues: Bool, pattern: String, codeLength: Int32?)
|
case confirm(password: String?, hasSecureValues: Bool, pattern: String, codeLength: Int32?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,8 +326,18 @@ final class SetupTwoStepVerificationControllerNode: ViewControllerTracingNode {
|
|||||||
}, transition: .animated(duration: 0.5, curve: .spring))
|
}, transition: .animated(duration: 0.5, curve: .spring))
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
case let .add(_, _, email):
|
case let .add(password, hadRecoveryEmail, hasSecureValues, email):
|
||||||
emailPattern = email
|
emailPattern = email
|
||||||
|
leftAction = SetupTwoStepVerificationContentAction(title: "Change E-Mail", action: { [weak self] in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.updateState({ state in
|
||||||
|
var state = state
|
||||||
|
state.data.state = .enterEmail(state: .add(hadRecoveryEmail: hadRecoveryEmail, hasSecureValues: hasSecureValues, password: password), email: "")
|
||||||
|
return state
|
||||||
|
}, transition: .animated(duration: 0.5, curve: .spring))
|
||||||
|
})
|
||||||
case let .confirm(_, _, pattern, _):
|
case let .confirm(_, _, pattern, _):
|
||||||
emailPattern = pattern
|
emailPattern = pattern
|
||||||
}
|
}
|
||||||
@ -541,7 +551,7 @@ final class SetupTwoStepVerificationControllerNode: ViewControllerTracingNode {
|
|||||||
return state
|
return state
|
||||||
}, transition: .animated(duration: 0.5, curve: .spring))
|
}, transition: .animated(duration: 0.5, curve: .spring))
|
||||||
}))
|
}))
|
||||||
case let .add(_, hasSecureValues, password):
|
case let .add(hadRecoveryEmail, hasSecureValues, password):
|
||||||
strongSelf.updateState({ state in
|
strongSelf.updateState({ state in
|
||||||
var state = state
|
var state = state
|
||||||
state.data.activity = true
|
state.data.activity = true
|
||||||
@ -561,7 +571,7 @@ final class SetupTwoStepVerificationControllerNode: ViewControllerTracingNode {
|
|||||||
break
|
break
|
||||||
case let .password(password, pendingEmail):
|
case let .password(password, pendingEmail):
|
||||||
if let pendingEmail = pendingEmail {
|
if let pendingEmail = pendingEmail {
|
||||||
state.data.state = .confirmEmail(state: .add(password: password, hasSecureValues: hasSecureValues, email: email), pattern: pendingEmail.pattern, codeLength: pendingEmail.codeLength, code: "")
|
state.data.state = .confirmEmail(state: .add(password: password, hadRecoveryEmail: hadRecoveryEmail, hasSecureValues: hasSecureValues, email: email), pattern: pendingEmail.pattern, codeLength: pendingEmail.codeLength, code: "")
|
||||||
strongSelf.stateUpdated(.awaitingEmailConfirmation(password: password, pattern: pendingEmail.pattern, codeLength: pendingEmail.codeLength), false)
|
strongSelf.stateUpdated(.awaitingEmailConfirmation(password: password, pattern: pendingEmail.pattern, codeLength: pendingEmail.codeLength), false)
|
||||||
} else {
|
} else {
|
||||||
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: true, hasSecureValues: hasSecureValues), true)
|
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: true, hasSecureValues: hasSecureValues), true)
|
||||||
@ -598,6 +608,7 @@ final class SetupTwoStepVerificationControllerNode: ViewControllerTracingNode {
|
|||||||
text = strongSelf.presentationData.strings.TwoStepAuth_EmailInvalid
|
text = strongSelf.presentationData.strings.TwoStepAuth_EmailInvalid
|
||||||
case .invalidCode:
|
case .invalidCode:
|
||||||
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
||||||
|
strongSelf.contentNode?.dataEntryError()
|
||||||
case .expired:
|
case .expired:
|
||||||
text = strongSelf.presentationData.strings.TwoStepAuth_EmailCodeExpired
|
text = strongSelf.presentationData.strings.TwoStepAuth_EmailCodeExpired
|
||||||
case .flood:
|
case .flood:
|
||||||
@ -619,7 +630,7 @@ final class SetupTwoStepVerificationControllerNode: ViewControllerTracingNode {
|
|||||||
switch confirmState {
|
switch confirmState {
|
||||||
case let .create(password, _, _):
|
case let .create(password, _, _):
|
||||||
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: true, hasSecureValues: false), true)
|
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: true, hasSecureValues: false), true)
|
||||||
case let .add(password, hasSecureValues, email):
|
case let .add(password, _, hasSecureValues, email):
|
||||||
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: !email.isEmpty, hasSecureValues: hasSecureValues), true)
|
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: !email.isEmpty, hasSecureValues: hasSecureValues), true)
|
||||||
case let .confirm(password, hasSecureValues, _, _):
|
case let .confirm(password, hasSecureValues, _, _):
|
||||||
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: true, hasSecureValues: hasSecureValues), true)
|
strongSelf.stateUpdated(.passwordSet(password: password, hasRecoveryEmail: true, hasSecureValues: hasSecureValues), true)
|
||||||
|
@ -471,6 +471,9 @@ func twoStepVerificationUnlockSettingsController(account: Account, mode: TwoStep
|
|||||||
dataPromise.set(.single(TwoStepVerificationUnlockSettingsControllerData.access(configuration: .notSet(pendingEmail: nil))))
|
dataPromise.set(.single(TwoStepVerificationUnlockSettingsControllerData.access(configuration: .notSet(pendingEmail: nil))))
|
||||||
controller?.view.endEditing(true)
|
controller?.view.endEditing(true)
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
|
|
||||||
|
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
|
||||||
|
presentControllerImpl?(OverlayStatusController(theme: presentationData.theme, strings: presentationData.strings, type: .genericSuccess(presentationData.strings.TwoStepAuth_DisableSuccess)), nil)
|
||||||
}
|
}
|
||||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||||
}, error: { _ in
|
}, error: { _ in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user