From 844392f644775003e4d7a046a7f81d83fe838ac1 Mon Sep 17 00:00:00 2001 From: overtake <> Date: Tue, 28 Aug 2018 12:48:40 +0300 Subject: [PATCH] no message --- TelegramCore/AccessSecureId.swift | 8 ++++---- TelegramCore/TwoStepVerification.swift | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/TelegramCore/AccessSecureId.swift b/TelegramCore/AccessSecureId.swift index b1467eb29e..054a3f2de7 100644 --- a/TelegramCore/AccessSecureId.swift +++ b/TelegramCore/AccessSecureId.swift @@ -160,15 +160,15 @@ public enum SecureIdAccessError { case secretPasswordMismatch } -public func accessSecureId(network: Network, password: String) -> Signal { +public func accessSecureId(network: Network, password: String) -> Signal<(context: SecureIdAccessContext, settings: TwoStepVerificationSettings), SecureIdAccessError> { return requestTwoStepVerifiationSettings(network: network, password: password) |> mapError { error -> SecureIdAccessError in return .passwordError(error) } - |> mapToSignal { settings -> Signal in + |> mapToSignal { settings -> Signal<(context: SecureIdAccessContext, settings: TwoStepVerificationSettings), SecureIdAccessError> in if let secureSecret = settings.secureSecret { if let decryptedSecret = decryptedSecureSecret(encryptedSecretData: secureSecret.data, password: password, derivation: secureSecret.derivation, id: secureSecret.id) { - return .single(SecureIdAccessContext(secret: decryptedSecret, id: secureSecret.id)) + return .single((SecureIdAccessContext(secret: decryptedSecret, id: secureSecret.id), settings)) } else { return .fail(.secretPasswordMismatch) } @@ -183,7 +183,7 @@ public func accessSecureId(network: Network, password: String) -> Signal) -> Void in memcpy(&secretId, bytes, 8) } - return SecureIdAccessContext(secret: decryptedSecret, id: secretId) + return (SecureIdAccessContext(secret: decryptedSecret, id: secretId), settings) } } } diff --git a/TelegramCore/TwoStepVerification.swift b/TelegramCore/TwoStepVerification.swift index 252e160290..75e3e57d24 100644 --- a/TelegramCore/TwoStepVerification.swift +++ b/TelegramCore/TwoStepVerification.swift @@ -61,8 +61,14 @@ public func requestTwoStepVerifiationSettings(network: Network, password: String } return network.request(Api.functions.account.getPasswordSettings(password: .inputCheckPasswordSRP(srpId: kdfResult.id, A: Buffer(data: kdfResult.A), M1: Buffer(data: kdfResult.M1))), automaticFloodWait: false) - |> mapError { _ -> AuthorizationPasswordVerificationError in - return .generic + |> mapError { error -> AuthorizationPasswordVerificationError in + if error.errorDescription.hasPrefix("FLOOD_WAIT") { + return .limitExceeded + } else if error.errorDescription == "PASSWORD_HASH_INVALID" { + return .invalidPassword + } else { + return .generic + } } |> mapToSignal { result -> Signal in switch result {