mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various fixes
This commit is contained in:
@@ -7998,6 +7998,12 @@ Sorry for the inconvenience.";
|
|||||||
"Login.WrongCodeError" = "Wrong code, please try again.";
|
"Login.WrongCodeError" = "Wrong code, please try again.";
|
||||||
|
|
||||||
"PrivacySettings.LoginEmail" = "Login Email";
|
"PrivacySettings.LoginEmail" = "Login Email";
|
||||||
|
"Login.EmailChanged" = "Your email has been changed.";
|
||||||
|
|
||||||
|
"Login.InvalidEmailAddressError" = "An error occurred. Please try again.";
|
||||||
|
"Login.InvalidEmailError" = "Please enter a valid e-mail address.";
|
||||||
|
"Login.InvalidEmailTokenError" = "An error occurred. Please try again.";
|
||||||
|
"Login.EmailNotAllowedError" = "Sorry, this email can't be used.";
|
||||||
|
|
||||||
"Conversation.EmojiCopied" = "Emoji copied to clipboard";
|
"Conversation.EmojiCopied" = "Emoji copied to clipboard";
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
|||||||
self.controllerNode.activateInput()
|
self.controllerNode.activateInput()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resetCode() {
|
public func resetCode() {
|
||||||
self.controllerNode.resetCode()
|
self.controllerNode.resetCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -302,30 +302,38 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
|||||||
if let strongSelf = self, let controller = controller {
|
if let strongSelf = self, let controller = controller {
|
||||||
controller.inProgress = false
|
controller.inProgress = false
|
||||||
|
|
||||||
var resetCode = false
|
if case .invalidCode = error {
|
||||||
let text: String
|
controller.animateError(text: strongSelf.presentationData.strings.Login_WrongCodeError)
|
||||||
switch error {
|
} else {
|
||||||
case .limitExceeded:
|
var resetCode = false
|
||||||
resetCode = true
|
let text: String
|
||||||
text = strongSelf.presentationData.strings.Login_CodeFloodError
|
switch error {
|
||||||
case .invalidCode:
|
case .limitExceeded:
|
||||||
resetCode = true
|
resetCode = true
|
||||||
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
text = strongSelf.presentationData.strings.Login_CodeFloodError
|
||||||
case .generic:
|
case .invalidCode:
|
||||||
text = strongSelf.presentationData.strings.Login_UnknownError
|
resetCode = true
|
||||||
case .codeExpired:
|
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
||||||
text = strongSelf.presentationData.strings.Login_CodeExpired
|
case .generic:
|
||||||
let account = strongSelf.account
|
text = strongSelf.presentationData.strings.Login_UnknownError
|
||||||
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).start()
|
case .codeExpired:
|
||||||
case .timeout:
|
text = strongSelf.presentationData.strings.Login_CodeExpired
|
||||||
text = strongSelf.presentationData.strings.Login_NetworkError
|
let account = strongSelf.account
|
||||||
|
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).start()
|
||||||
|
case .timeout:
|
||||||
|
text = strongSelf.presentationData.strings.Login_NetworkError
|
||||||
|
case .invalidEmailToken:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError
|
||||||
|
case .emailNotAllowed:
|
||||||
|
text = strongSelf.presentationData.strings.Login_EmailNotAllowedError
|
||||||
|
}
|
||||||
|
|
||||||
|
if resetCode {
|
||||||
|
controller.resetCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||||
}
|
}
|
||||||
|
|
||||||
if resetCode {
|
|
||||||
controller.resetCode()
|
|
||||||
}
|
|
||||||
|
|
||||||
controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -420,6 +428,10 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
|||||||
text = strongSelf.presentationData.strings.Login_CodeExpired
|
text = strongSelf.presentationData.strings.Login_CodeExpired
|
||||||
let account = strongSelf.account
|
let account = strongSelf.account
|
||||||
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).start()
|
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).start()
|
||||||
|
case .invalidEmailToken:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError
|
||||||
|
case .invalidEmailAddress:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailAddressError
|
||||||
}
|
}
|
||||||
|
|
||||||
if resetCode {
|
if resetCode {
|
||||||
@@ -550,6 +562,10 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
|||||||
text = strongSelf.presentationData.strings.Login_UnknownError
|
text = strongSelf.presentationData.strings.Login_UnknownError
|
||||||
case .timeout:
|
case .timeout:
|
||||||
text = strongSelf.presentationData.strings.Login_NetworkError
|
text = strongSelf.presentationData.strings.Login_NetworkError
|
||||||
|
case .invalidEmail:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailError
|
||||||
|
case .emailNotAllowed:
|
||||||
|
text = strongSelf.presentationData.strings.Login_EmailNotAllowedError
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||||
@@ -610,6 +626,10 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
|||||||
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
||||||
case .timeout:
|
case .timeout:
|
||||||
text = strongSelf.presentationData.strings.Login_NetworkError
|
text = strongSelf.presentationData.strings.Login_NetworkError
|
||||||
|
case .invalidEmailToken:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError
|
||||||
|
case .emailNotAllowed:
|
||||||
|
text = strongSelf.presentationData.strings.Login_EmailNotAllowedError
|
||||||
}
|
}
|
||||||
lastController.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
lastController.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||||
}
|
}
|
||||||
@@ -649,6 +669,10 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
|||||||
text = strongSelf.presentationData.strings.Login_CodeExpired
|
text = strongSelf.presentationData.strings.Login_CodeExpired
|
||||||
let account = strongSelf.account
|
let account = strongSelf.account
|
||||||
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).start()
|
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).start()
|
||||||
|
case .invalidEmailToken:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError
|
||||||
|
case .invalidEmailAddress:
|
||||||
|
text = strongSelf.presentationData.strings.Login_InvalidEmailAddressError
|
||||||
}
|
}
|
||||||
|
|
||||||
lastController.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
lastController.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import PasswordSetupUI
|
|||||||
import UndoUI
|
import UndoUI
|
||||||
import PremiumUI
|
import PremiumUI
|
||||||
import AuthorizationUI
|
import AuthorizationUI
|
||||||
|
import AuthenticationServices
|
||||||
|
|
||||||
private final class PrivacyAndSecurityControllerArguments {
|
private final class PrivacyAndSecurityControllerArguments {
|
||||||
let account: Account
|
let account: Account
|
||||||
@@ -1082,11 +1083,76 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
|||||||
let codeController = AuthorizationSequenceCodeEntryController(presentationData: presentationData, openUrl: { _ in }, back: {
|
let codeController = AuthorizationSequenceCodeEntryController(presentationData: presentationData, openUrl: { _ in }, back: {
|
||||||
dismissCodeControllerImpl?()
|
dismissCodeControllerImpl?()
|
||||||
})
|
})
|
||||||
codeController.loginWithCode = { code in
|
codeController.loginWithCode = { [weak codeController] code in
|
||||||
|
actionsDisposable.add((verifyLoginEmailChange(account: context.account, code: .emailCode(code))
|
||||||
|
|> deliverOnMainQueue).start(error: { error in
|
||||||
|
Queue.mainQueue().async {
|
||||||
|
codeController?.inProgress = false
|
||||||
|
|
||||||
|
if case .invalidCode = error {
|
||||||
|
codeController?.animateError(text: presentationData.strings.Login_WrongCodeError)
|
||||||
|
} else {
|
||||||
|
var resetCode = false
|
||||||
|
let text: String
|
||||||
|
switch error {
|
||||||
|
case .limitExceeded:
|
||||||
|
resetCode = true
|
||||||
|
text = presentationData.strings.Login_CodeFloodError
|
||||||
|
case .invalidCode:
|
||||||
|
resetCode = true
|
||||||
|
text = presentationData.strings.Login_InvalidCodeError
|
||||||
|
case .generic:
|
||||||
|
text = presentationData.strings.Login_UnknownError
|
||||||
|
case .codeExpired:
|
||||||
|
text = presentationData.strings.Login_CodeExpired
|
||||||
|
case .timeout:
|
||||||
|
text = presentationData.strings.Login_NetworkError
|
||||||
|
case .invalidEmailToken:
|
||||||
|
text = presentationData.strings.Login_InvalidEmailTokenError
|
||||||
|
case .emailNotAllowed:
|
||||||
|
text = presentationData.strings.Login_EmailNotAllowedError
|
||||||
|
}
|
||||||
|
|
||||||
|
if resetCode {
|
||||||
|
codeController?.resetCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
presentControllerImpl?(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, completed: { [weak codeController] in
|
||||||
|
codeController?.animateSuccess()
|
||||||
|
Queue.mainQueue().after(0.75) {
|
||||||
|
if let navigationController = getNavigationControllerImpl?() {
|
||||||
|
let controllers = navigationController.viewControllers.filter { controller in
|
||||||
|
if controller is AuthorizationSequenceEmailEntryController || controller is AuthorizationSequenceCodeEntryController {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
|
|
||||||
|
navigationController.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .emoji(name: "IntroLetter", text: presentationData.strings.Login_EmailChanged), elevatedLayout: false, animateInAsReplacement: false, action: { _ in
|
||||||
|
return false
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
codeController.signInWithApple = {
|
codeController.signInWithApple = {
|
||||||
|
// if #available(iOS 13.0, *) {
|
||||||
|
// let appleIdProvider = ASAuthorizationAppleIDProvider()
|
||||||
|
// let passwordProvider = ASAuthorizationPasswordProvider()
|
||||||
|
// let request = appleIdProvider.createRequest()
|
||||||
|
//
|
||||||
|
// let passwordRequest = passwordProvider.createRequest()
|
||||||
|
//
|
||||||
|
// let authorizationController = ASAuthorizationController(authorizationRequests: [request, passwordRequest])
|
||||||
|
// authorizationController.delegate = strongSelf
|
||||||
|
// authorizationController.presentationContextProvider = strongSelf
|
||||||
|
// authorizationController.performRequests()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
codeController.updateData(number: "", email: email, codeType: .email(emailPattern: "", length: data.length, nextPhoneLoginDate: nil, appleSignInAllowed: false, setup: true), nextType: nil, timeout: nil, termsOfService: nil)
|
codeController.updateData(number: "", email: email, codeType: .email(emailPattern: "", length: data.length, nextPhoneLoginDate: nil, appleSignInAllowed: false, setup: true), nextType: nil, timeout: nil, termsOfService: nil)
|
||||||
pushControllerImpl?(codeController, true)
|
pushControllerImpl?(codeController, true)
|
||||||
@@ -1104,6 +1170,10 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
|||||||
text = presentationData.strings.Login_UnknownError
|
text = presentationData.strings.Login_UnknownError
|
||||||
case .timeout:
|
case .timeout:
|
||||||
text = presentationData.strings.Login_NetworkError
|
text = presentationData.strings.Login_NetworkError
|
||||||
|
case .invalidEmail:
|
||||||
|
text = presentationData.strings.Login_InvalidEmailError
|
||||||
|
case .emailNotAllowed:
|
||||||
|
text = presentationData.strings.Login_EmailNotAllowedError
|
||||||
}
|
}
|
||||||
|
|
||||||
presentControllerImpl?(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]))
|
presentControllerImpl?(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]))
|
||||||
|
|||||||
@@ -231,6 +231,8 @@ public enum AuthorizationCodeVerificationError {
|
|||||||
case limitExceeded
|
case limitExceeded
|
||||||
case generic
|
case generic
|
||||||
case codeExpired
|
case codeExpired
|
||||||
|
case invalidEmailToken
|
||||||
|
case invalidEmailAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum AuthorizationCodeResult {
|
private enum AuthorizationCodeResult {
|
||||||
@@ -312,6 +314,8 @@ public enum AuthorizationSendEmailCodeError {
|
|||||||
case limitExceeded
|
case limitExceeded
|
||||||
case codeExpired
|
case codeExpired
|
||||||
case timeout
|
case timeout
|
||||||
|
case invalidEmail
|
||||||
|
case emailNotAllowed
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AuthorizationEmailVerificationError {
|
public enum AuthorizationEmailVerificationError {
|
||||||
@@ -320,6 +324,8 @@ public enum AuthorizationEmailVerificationError {
|
|||||||
case codeExpired
|
case codeExpired
|
||||||
case invalidCode
|
case invalidCode
|
||||||
case timeout
|
case timeout
|
||||||
|
case invalidEmailToken
|
||||||
|
case emailNotAllowed
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ChangeLoginEmailData: Equatable {
|
public struct ChangeLoginEmailData: Equatable {
|
||||||
@@ -335,6 +341,10 @@ public func sendLoginEmailChangeCode(account: Account, email: String) -> Signal<
|
|||||||
return .fail(.limitExceeded)
|
return .fail(.limitExceeded)
|
||||||
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
||||||
return .fail(.codeExpired)
|
return .fail(.codeExpired)
|
||||||
|
} else if errorDescription.hasPrefix("EMAIL_INVALID") {
|
||||||
|
return .fail(.invalidEmail)
|
||||||
|
} else if errorDescription.hasPrefix("EMAIL_NOT_ALLOWED") {
|
||||||
|
return .fail(.emailNotAllowed)
|
||||||
} else {
|
} else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
@@ -359,6 +369,10 @@ public func sendLoginEmailCode(account: UnauthorizedAccount, email: String) -> S
|
|||||||
return .fail(.limitExceeded)
|
return .fail(.limitExceeded)
|
||||||
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
||||||
return .fail(.codeExpired)
|
return .fail(.codeExpired)
|
||||||
|
} else if errorDescription.hasPrefix("EMAIL_INVALID") {
|
||||||
|
return .fail(.invalidEmail)
|
||||||
|
} else if errorDescription.hasPrefix("EMAIL_NOT_ALLOWED") {
|
||||||
|
return .fail(.emailNotAllowed)
|
||||||
} else {
|
} else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
@@ -389,6 +403,39 @@ public func sendLoginEmailCode(account: UnauthorizedAccount, email: String) -> S
|
|||||||
|> ignoreValues
|
|> ignoreValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func verifyLoginEmailChange(account: Account, code: AuthorizationCode.EmailVerification) -> Signal<Never, AuthorizationEmailVerificationError> {
|
||||||
|
let verification: Api.EmailVerification
|
||||||
|
switch code {
|
||||||
|
case let .emailCode(code):
|
||||||
|
verification = .emailVerificationCode(code: code)
|
||||||
|
case let .appleToken(token):
|
||||||
|
verification = .emailVerificationApple(token: token)
|
||||||
|
case let .googleToken(token):
|
||||||
|
verification = .emailVerificationGoogle(token: token)
|
||||||
|
}
|
||||||
|
|
||||||
|
return account.network.request(Api.functions.account.verifyEmail(purpose: .emailVerifyPurposeLoginChange, verification: verification), automaticFloodWait: false)
|
||||||
|
|> `catch` { error -> Signal<Api.account.EmailVerified, AuthorizationEmailVerificationError> in
|
||||||
|
let errorDescription = error.errorDescription ?? ""
|
||||||
|
if errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||||
|
return .fail(.limitExceeded)
|
||||||
|
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" || errorDescription == "EMAIL_VERIFY_EXPIRED" {
|
||||||
|
return .fail(.codeExpired)
|
||||||
|
} else if errorDescription == "CODE_INVALID" {
|
||||||
|
return .fail(.invalidCode)
|
||||||
|
} else if errorDescription == "EMAIL_TOKEN_INVALID" {
|
||||||
|
return .fail(.invalidEmailToken)
|
||||||
|
} else if errorDescription == "EMAIL_NOT_ALLOWED" {
|
||||||
|
return .fail(.emailNotAllowed)
|
||||||
|
} else {
|
||||||
|
return .fail(.generic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|> mapToSignal { _ -> Signal<Never, AuthorizationEmailVerificationError> in
|
||||||
|
return .never()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func verifyLoginEmailSetup(account: UnauthorizedAccount, code: AuthorizationCode.EmailVerification) -> Signal<Never, AuthorizationEmailVerificationError> {
|
public func verifyLoginEmailSetup(account: UnauthorizedAccount, code: AuthorizationCode.EmailVerification) -> Signal<Never, AuthorizationEmailVerificationError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<Never, AuthorizationEmailVerificationError> in
|
return account.postbox.transaction { transaction -> Signal<Never, AuthorizationEmailVerificationError> in
|
||||||
if let state = transaction.getState() as? UnauthorizedAccountState {
|
if let state = transaction.getState() as? UnauthorizedAccountState {
|
||||||
@@ -409,10 +456,14 @@ public func verifyLoginEmailSetup(account: UnauthorizedAccount, code: Authorizat
|
|||||||
let errorDescription = error.errorDescription ?? ""
|
let errorDescription = error.errorDescription ?? ""
|
||||||
if errorDescription.hasPrefix("FLOOD_WAIT") {
|
if errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||||
return .fail(.limitExceeded)
|
return .fail(.limitExceeded)
|
||||||
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" || errorDescription == "EMAIL_VERIFY_EXPIRED" {
|
||||||
return .fail(.codeExpired)
|
return .fail(.codeExpired)
|
||||||
} else if errorDescription == "" {
|
} else if errorDescription == "CODE_INVALID" {
|
||||||
return .fail(.invalidCode)
|
return .fail(.invalidCode)
|
||||||
|
} else if errorDescription == "EMAIL_TOKEN_INVALID" {
|
||||||
|
return .fail(.invalidEmailToken)
|
||||||
|
} else if errorDescription == "EMAIL_NOT_ALLOWED" {
|
||||||
|
return .fail(.emailNotAllowed)
|
||||||
} else {
|
} else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
@@ -502,12 +553,16 @@ public func authorizeWithCode(accountManager: AccountManager<TelegramAccountMana
|
|||||||
case let (_, errorDescription):
|
case let (_, errorDescription):
|
||||||
if errorDescription.hasPrefix("FLOOD_WAIT") {
|
if errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||||
return .fail(.limitExceeded)
|
return .fail(.limitExceeded)
|
||||||
} else if errorDescription == "PHONE_CODE_INVALID" {
|
} else if errorDescription == "PHONE_CODE_INVALID" || errorDescription == "EMAIL_CODE_INVALID" {
|
||||||
return .fail(.invalidCode)
|
return .fail(.invalidCode)
|
||||||
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
} else if errorDescription == "CODE_HASH_EXPIRED" || errorDescription == "PHONE_CODE_EXPIRED" {
|
||||||
return .fail(.codeExpired)
|
return .fail(.codeExpired)
|
||||||
} else if errorDescription == "PHONE_NUMBER_UNOCCUPIED" {
|
} else if errorDescription == "PHONE_NUMBER_UNOCCUPIED" {
|
||||||
return .single(.signUp)
|
return .single(.signUp)
|
||||||
|
} else if errorDescription == "EMAIL_TOKEN_INVALID" {
|
||||||
|
return .fail(.invalidEmailToken)
|
||||||
|
} else if errorDescription == "EMAIL_ADDRESS_INVALID" {
|
||||||
|
return .fail(.invalidEmailAddress)
|
||||||
} else {
|
} else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user