mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Revert API
This commit is contained in:
parent
63a313b1cf
commit
e6c5c163e3
@ -475,7 +475,7 @@ public final class TwoFactorDataInputScreen: ViewController {
|
||||
}
|
||||
|
||||
private func performRecovery(recovery: TwoFactorDataInputMode.Recovery, password: String, hint: String) {
|
||||
let statusController = OverlayStatusController(theme: self.presentationData.theme, type: .loading(cancelled: nil))
|
||||
/*let statusController = OverlayStatusController(theme: self.presentationData.theme, type: .loading(cancelled: nil))
|
||||
self.present(statusController, in: .window(.root))
|
||||
|
||||
let _ = (performPasswordRecovery(accountManager: self.sharedContext.accountManager, account: recovery.account, code: recovery.code, syncContacts: recovery.syncContacts, updatedPassword: password.isEmpty ? .none : .password(password: password, hint: hint, email: nil))
|
||||
@ -507,7 +507,7 @@ public final class TwoFactorDataInputScreen: ViewController {
|
||||
}
|
||||
|
||||
strongSelf.dismiss()
|
||||
})
|
||||
})*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,8 @@ private final class TwoStepVerificationUnlockSettingsControllerArguments {
|
||||
let openResetPendingEmail: () -> Void
|
||||
let updateEmailCode: (String) -> Void
|
||||
let openConfirmEmail: () -> Void
|
||||
let declinePasswordReset: () -> Void
|
||||
|
||||
init(updatePasswordText: @escaping (String) -> Void, checkPassword: @escaping () -> Void, openForgotPassword: @escaping () -> Void, openSetupPassword: @escaping () -> Void, openDisablePassword: @escaping () -> Void, openSetupEmail: @escaping () -> Void, openResetPendingEmail: @escaping () -> Void, updateEmailCode: @escaping (String) -> Void, openConfirmEmail: @escaping () -> Void, declinePasswordReset: @escaping () -> Void) {
|
||||
init(updatePasswordText: @escaping (String) -> Void, checkPassword: @escaping () -> Void, openForgotPassword: @escaping () -> Void, openSetupPassword: @escaping () -> Void, openDisablePassword: @escaping () -> Void, openSetupEmail: @escaping () -> Void, openResetPendingEmail: @escaping () -> Void, updateEmailCode: @escaping (String) -> Void, openConfirmEmail: @escaping () -> Void) {
|
||||
self.updatePasswordText = updatePasswordText
|
||||
self.checkPassword = checkPassword
|
||||
self.openForgotPassword = openForgotPassword
|
||||
@ -38,7 +37,6 @@ private final class TwoStepVerificationUnlockSettingsControllerArguments {
|
||||
self.openResetPendingEmail = openResetPendingEmail
|
||||
self.updateEmailCode = updateEmailCode
|
||||
self.openConfirmEmail = openConfirmEmail
|
||||
self.declinePasswordReset = declinePasswordReset
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,51 +132,47 @@ private enum TwoStepVerificationUnlockSettingsEntry: ItemListNodeEntry {
|
||||
}, action: {
|
||||
arguments.checkPassword()
|
||||
})
|
||||
case let .passwordEntryInfo(_, text):
|
||||
case let .passwordEntryInfo(theme, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section, linkAction: { action in
|
||||
switch action {
|
||||
case let .tap(item):
|
||||
if item == "forgot" {
|
||||
arguments.openForgotPassword()
|
||||
} else if item == "declineReset" {
|
||||
arguments.declinePasswordReset()
|
||||
}
|
||||
case .tap:
|
||||
arguments.openForgotPassword()
|
||||
}
|
||||
})
|
||||
case let .passwordSetup(_, text):
|
||||
case let .passwordSetup(theme, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openSetupPassword()
|
||||
})
|
||||
case let .passwordSetupInfo(_, text):
|
||||
case let .passwordSetupInfo(theme, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
||||
case let .changePassword(_, text):
|
||||
case let .changePassword(theme, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openSetupPassword()
|
||||
})
|
||||
case let .turnPasswordOff(_, text):
|
||||
case let .turnPasswordOff(theme, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openDisablePassword()
|
||||
})
|
||||
case let .setupRecoveryEmail(_, text):
|
||||
case let .setupRecoveryEmail(theme, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openSetupEmail()
|
||||
})
|
||||
case let .passwordInfo(_, text):
|
||||
case let .passwordInfo(theme, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .pendingEmailConfirmInfo(_, text):
|
||||
case let .pendingEmailConfirmInfo(theme, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .pendingEmailConfirmCode(_, _, title, text):
|
||||
case let .pendingEmailConfirmCode(theme, strings, title, text):
|
||||
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(string: ""), text: text, placeholder: title, type: .number, sectionId: self.section, textUpdated: { value in
|
||||
arguments.updateEmailCode(value)
|
||||
}, action: {})
|
||||
case let .pendingEmailInfo(_, text):
|
||||
case let .pendingEmailInfo(theme, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section, linkAction: { action in
|
||||
switch action {
|
||||
case .tap:
|
||||
arguments.openResetPendingEmail()
|
||||
}
|
||||
})
|
||||
case let .pendingEmailOpenConfirm(_, text):
|
||||
case let .pendingEmailOpenConfirm(theme, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openConfirmEmail()
|
||||
})
|
||||
@ -210,27 +204,13 @@ private func twoStepVerificationUnlockSettingsControllerEntries(presentationData
|
||||
entries.append(.passwordSetup(presentationData.theme, presentationData.strings.TwoStepAuth_SetPassword))
|
||||
entries.append(.passwordSetupInfo(presentationData.theme, presentationData.strings.TwoStepAuth_SetPasswordHelp))
|
||||
}
|
||||
case let .set(hint, _, _, pendingResetTimestamp):
|
||||
case let .set(hint, _, _):
|
||||
entries.append(.passwordEntry(presentationData.theme, presentationData.strings, presentationData.strings.TwoStepAuth_EnterPasswordPassword, state.passwordText))
|
||||
var text: String = presentationData.strings.TwoStepAuth_EnterPasswordHint(escapedPlaintextForMarkdown(hint)).0 + "\n\n" + presentationData.strings.TwoStepAuth_EnterPasswordHelp + "\n\n[" + presentationData.strings.TwoStepAuth_EnterPasswordForgot + "](forgot)"
|
||||
if !hint.isEmpty {
|
||||
text = presentationData.strings.TwoStepAuth_EnterPasswordHint(escapedPlaintextForMarkdown(hint)).0 + "\n\n" + presentationData.strings.TwoStepAuth_EnterPasswordHelp + "\n\n[" + presentationData.strings.TwoStepAuth_EnterPasswordForgot + "](forgot)"
|
||||
if hint.isEmpty {
|
||||
entries.append(.passwordEntryInfo(presentationData.theme, presentationData.strings.TwoStepAuth_EnterPasswordHelp + "\n\n[" + presentationData.strings.TwoStepAuth_EnterPasswordForgot + "](forgot)"))
|
||||
} else {
|
||||
text = presentationData.strings.TwoStepAuth_EnterPasswordHelp + "\n\n[" + presentationData.strings.TwoStepAuth_EnterPasswordForgot + "](forgot)"
|
||||
entries.append(.passwordEntryInfo(presentationData.theme, presentationData.strings.TwoStepAuth_EnterPasswordHint(escapedPlaintextForMarkdown(hint)).0 + "\n\n" + presentationData.strings.TwoStepAuth_EnterPasswordHelp + "\n\n[" + presentationData.strings.TwoStepAuth_EnterPasswordForgot + "](forgot)"))
|
||||
}
|
||||
|
||||
if let pendingResetTimestamp = pendingResetTimestamp {
|
||||
let remainingSeconds = pendingResetTimestamp - Int32(Date().timeIntervalSince1970)
|
||||
if remainingSeconds <= 0 {
|
||||
text.append("\nPassword reset is available")
|
||||
} else {
|
||||
text.append("\nPassword reset available in \(remainingSeconds) s")
|
||||
}
|
||||
|
||||
text.append("\n[Cancel reset](declineReset)")
|
||||
}
|
||||
|
||||
entries.append(.passwordEntryInfo(presentationData.theme, text))
|
||||
}
|
||||
}
|
||||
case let .manage(_, emailSet, pendingEmail, _):
|
||||
@ -260,14 +240,14 @@ struct TwoStepVerificationPendingEmailState: Equatable {
|
||||
|
||||
enum TwoStepVerificationAccessConfiguration: Equatable {
|
||||
case notSet(pendingEmail: TwoStepVerificationPendingEmailState?)
|
||||
case set(hint: String, hasRecoveryEmail: Bool, hasSecureValues: Bool, pendingResetTimestamp: Int32?)
|
||||
case set(hint: String, hasRecoveryEmail: Bool, hasSecureValues: Bool)
|
||||
|
||||
init(configuration: TwoStepVerificationConfiguration, password: String?) {
|
||||
switch configuration {
|
||||
case let .notSet(pendingEmail):
|
||||
self = .notSet(pendingEmail: pendingEmail.flatMap({ TwoStepVerificationPendingEmailState(password: password, email: $0) }))
|
||||
case let .set(hint, hasRecoveryEmail, _, hasSecureValues, pendingResetTimestamp):
|
||||
self = .set(hint: hint, hasRecoveryEmail: hasRecoveryEmail, hasSecureValues: hasSecureValues, pendingResetTimestamp: pendingResetTimestamp)
|
||||
case let .set(hint, hasRecoveryEmail, _, hasSecureValues, _):
|
||||
self = .set(hint: hint, hasRecoveryEmail: hasRecoveryEmail, hasSecureValues: hasSecureValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,6 +420,7 @@ func twoStepVerificationUnlockSettingsController(context: AccountContext, mode:
|
||||
|> mapToSignal { settings -> Signal<(TwoStepVerificationSettings, TwoStepVerificationPendingEmail?), AuthorizationPasswordVerificationError> in
|
||||
return twoStepVerificationConfiguration(account: context.account)
|
||||
|> mapError { _ -> AuthorizationPasswordVerificationError in
|
||||
return .generic
|
||||
}
|
||||
|> map { configuration in
|
||||
var pendingEmail: TwoStepVerificationPendingEmail?
|
||||
@ -488,7 +469,7 @@ func twoStepVerificationUnlockSettingsController(context: AccountContext, mode:
|
||||
if let configuration = configuration {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
switch configuration {
|
||||
case let .set(_, hasRecoveryEmail, _, pendingResetTimestamp):
|
||||
case let .set(_, hasRecoveryEmail, _):
|
||||
if hasRecoveryEmail {
|
||||
updateState { state in
|
||||
var state = state
|
||||
@ -525,23 +506,7 @@ func twoStepVerificationUnlockSettingsController(context: AccountContext, mode:
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}))
|
||||
} else {
|
||||
if true || pendingResetTimestamp == nil {
|
||||
let _ = (requestTwoStepPasswordReset(network: context.account.network)
|
||||
|> deliverOnMainQueue).start(next: { result in
|
||||
switch result {
|
||||
case .done, .waitingForReset:
|
||||
dataPromise.set(twoStepVerificationConfiguration(account: context.account)
|
||||
|> map { TwoStepVerificationUnlockSettingsControllerData.access(configuration: TwoStepVerificationAccessConfiguration(configuration: $0, password: nil))
|
||||
})
|
||||
case .declined:
|
||||
break
|
||||
case let .error(reason):
|
||||
break
|
||||
}
|
||||
})
|
||||
} else {
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.TwoStepAuth_RecoveryUnavailable, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.TwoStepAuth_RecoveryUnavailable, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
case .notSet:
|
||||
break
|
||||
@ -797,13 +762,6 @@ func twoStepVerificationUnlockSettingsController(context: AccountContext, mode:
|
||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
})
|
||||
}, declinePasswordReset: {
|
||||
let _ = (declineTwoStepPasswordReset(network: context.account.network)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
dataPromise.set(twoStepVerificationConfiguration(account: context.account)
|
||||
|> map { TwoStepVerificationUnlockSettingsControllerData.access(configuration: TwoStepVerificationAccessConfiguration(configuration: $0, password: nil))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var initialFocusImpl: (() -> Void)?
|
||||
|
@ -795,7 +795,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1908627474] = { return Api.SecureValueType.parse_secureValueTypeEmail($0) }
|
||||
dict[-732254058] = { return Api.PasswordKdfAlgo.parse_passwordKdfAlgoUnknown($0) }
|
||||
dict[982592842] = { return Api.PasswordKdfAlgo.parse_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow($0) }
|
||||
dict[408623183] = { return Api.account.Password.parse_password($0) }
|
||||
dict[-1390001672] = { return Api.account.Password.parse_password($0) }
|
||||
dict[-2000710887] = { return Api.InputBotInlineResult.parse_inputBotInlineResult($0) }
|
||||
dict[-1462213465] = { return Api.InputBotInlineResult.parse_inputBotInlineResultPhoto($0) }
|
||||
dict[-459324] = { return Api.InputBotInlineResult.parse_inputBotInlineResultDocument($0) }
|
||||
|
@ -1325,13 +1325,13 @@ public struct account {
|
||||
|
||||
}
|
||||
public enum Password: TypeConstructorDescription {
|
||||
case password(flags: Int32, currentAlgo: Api.PasswordKdfAlgo?, srpB: Buffer?, srpId: Int64?, hint: String?, emailUnconfirmedPattern: String?, newAlgo: Api.PasswordKdfAlgo, newSecureAlgo: Api.SecurePasswordKdfAlgo, secureRandom: Buffer, pendingResetDate: Int32?)
|
||||
case password(flags: Int32, currentAlgo: Api.PasswordKdfAlgo?, srpB: Buffer?, srpId: Int64?, hint: String?, emailUnconfirmedPattern: String?, newAlgo: Api.PasswordKdfAlgo, newSecureAlgo: Api.SecurePasswordKdfAlgo, secureRandom: Buffer)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .password(let flags, let currentAlgo, let srpB, let srpId, let hint, let emailUnconfirmedPattern, let newAlgo, let newSecureAlgo, let secureRandom, let pendingResetDate):
|
||||
case .password(let flags, let currentAlgo, let srpB, let srpId, let hint, let emailUnconfirmedPattern, let newAlgo, let newSecureAlgo, let secureRandom):
|
||||
if boxed {
|
||||
buffer.appendInt32(408623183)
|
||||
buffer.appendInt32(-1390001672)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 2) != 0 {currentAlgo!.serialize(buffer, true)}
|
||||
@ -1342,15 +1342,14 @@ public struct account {
|
||||
newAlgo.serialize(buffer, true)
|
||||
newSecureAlgo.serialize(buffer, true)
|
||||
serializeBytes(secureRandom, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 5) != 0 {serializeInt32(pendingResetDate!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .password(let flags, let currentAlgo, let srpB, let srpId, let hint, let emailUnconfirmedPattern, let newAlgo, let newSecureAlgo, let secureRandom, let pendingResetDate):
|
||||
return ("password", [("flags", flags), ("currentAlgo", currentAlgo), ("srpB", srpB), ("srpId", srpId), ("hint", hint), ("emailUnconfirmedPattern", emailUnconfirmedPattern), ("newAlgo", newAlgo), ("newSecureAlgo", newSecureAlgo), ("secureRandom", secureRandom), ("pendingResetDate", pendingResetDate)])
|
||||
case .password(let flags, let currentAlgo, let srpB, let srpId, let hint, let emailUnconfirmedPattern, let newAlgo, let newSecureAlgo, let secureRandom):
|
||||
return ("password", [("flags", flags), ("currentAlgo", currentAlgo), ("srpB", srpB), ("srpId", srpId), ("hint", hint), ("emailUnconfirmedPattern", emailUnconfirmedPattern), ("newAlgo", newAlgo), ("newSecureAlgo", newSecureAlgo), ("secureRandom", secureRandom)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -1379,8 +1378,6 @@ public struct account {
|
||||
}
|
||||
var _9: Buffer?
|
||||
_9 = parseBytes(reader)
|
||||
var _10: Int32?
|
||||
if Int(_1!) & Int(1 << 5) != 0 {_10 = reader.readInt32() }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 2) == 0) || _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil
|
||||
@ -1390,9 +1387,8 @@ public struct account {
|
||||
let _c7 = _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 5) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.account.Password.password(flags: _1!, currentAlgo: _2, srpB: _3, srpId: _4, hint: _5, emailUnconfirmedPattern: _6, newAlgo: _7!, newSecureAlgo: _8!, secureRandom: _9!, pendingResetDate: _10)
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.account.Password.password(flags: _1!, currentAlgo: _2, srpB: _3, srpId: _4, hint: _5, emailUnconfirmedPattern: _6, newAlgo: _7!, newSecureAlgo: _8!, secureRandom: _9!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -5254,13 +5250,11 @@ public extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
public static func recoverPassword(flags: Int32, code: String, newSettings: Api.account.PasswordInputSettings?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.auth.Authorization>) {
|
||||
public static func recoverPassword(code: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.auth.Authorization>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(923364464)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(1319464594)
|
||||
serializeString(code, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {newSettings!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "auth.recoverPassword", parameters: [("flags", flags), ("code", code), ("newSettings", newSettings)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.auth.Authorization? in
|
||||
return (FunctionDescription(name: "auth.recoverPassword", parameters: [("code", code)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.auth.Authorization? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.auth.Authorization?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -5365,20 +5359,6 @@ public extension Api {
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func checkRecoveryPassword(code: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(221691769)
|
||||
serializeString(code, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "auth.checkRecoveryPassword", parameters: [("code", code)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public struct bots {
|
||||
public static func sendCustomRequest(customMethod: String, params: Api.DataJSON) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.DataJSON>) {
|
||||
@ -5431,6 +5411,21 @@ public extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
public static func resetBotCommands(scope: Api.BotCommandScope, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1032708345)
|
||||
scope.serialize(buffer, true)
|
||||
serializeString(langCode, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "bots.resetBotCommands", parameters: [("scope", scope), ("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func getBotCommands(scope: Api.BotCommandScope, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.BotCommand]>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-481554986)
|
||||
@ -7507,34 +7502,6 @@ public extension Api {
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func resetPassword() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1517436040)
|
||||
|
||||
return (FunctionDescription(name: "account.resetPassword", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func declinePasswordReset() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1284770294)
|
||||
|
||||
return (FunctionDescription(name: "account.declinePasswordReset", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public struct langpack {
|
||||
public static func getLangPack(langPack: String, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.LangPackDifference>) {
|
||||
|
@ -377,7 +377,8 @@ public func twoStepAuthData(_ network: Network) -> Signal<TwoStepAuthData, MTRpc
|
||||
return network.request(Api.functions.account.getPassword())
|
||||
|> map { config -> TwoStepAuthData in
|
||||
switch config {
|
||||
case let .password(flags, currentAlgo, srpB, srpId, hint, emailUnconfirmedPattern, newAlgo, newSecureAlgo, secureRandom, pendingResetDate):
|
||||
case let .password(flags, currentAlgo, srpB, srpId, hint, emailUnconfirmedPattern, newAlgo, newSecureAlgo, secureRandom/*, pendingResetDate*/):
|
||||
let pendingResetDate: Int32? = nil
|
||||
let hasRecovery = (flags & (1 << 0)) != 0
|
||||
let hasSecureValues = (flags & (1 << 1)) != 0
|
||||
|
||||
|
@ -373,7 +373,41 @@ public enum PasswordRecoveryError {
|
||||
case generic
|
||||
}
|
||||
|
||||
public func checkPasswordRecoveryCode(network: Network, code: String) -> Signal<Never, PasswordRecoveryError> {
|
||||
public func performPasswordRecovery(accountManager: AccountManager, account: UnauthorizedAccount, code: String, syncContacts: Bool) -> Signal<Void, PasswordRecoveryError> {
|
||||
return account.network.request(Api.functions.auth.recoverPassword(code: code))
|
||||
|> mapError { error -> PasswordRecoveryError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
} else if error.errorDescription.hasPrefix("PASSWORD_RECOVERY_EXPIRED") {
|
||||
return .expired
|
||||
} else {
|
||||
return .invalidCode
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, PasswordRecoveryError> in
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
switch result {
|
||||
case let .authorization(_, _, user):
|
||||
let user = TelegramUser(user: user)
|
||||
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
|
||||
/*transaction.updatePeersInternal([user], update: { current, peer -> Peer? in
|
||||
return peer
|
||||
})*/
|
||||
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
|
||||
transaction.setState(state)
|
||||
return accountManager.transaction { transaction -> Void in
|
||||
switchToAuthorizedAccount(transaction: transaction, account: account)
|
||||
}
|
||||
case .authorizationSignUpRequired:
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|> switchToLatest
|
||||
|> mapError { _ -> PasswordRecoveryError in }
|
||||
}
|
||||
}
|
||||
|
||||
/*public func checkPasswordRecoveryCode(network: Network, code: String) -> Signal<Never, PasswordRecoveryError> {
|
||||
return network.request(Api.functions.auth.checkRecoveryPassword(code: code), automaticFloodWait: false)
|
||||
|> mapError { error -> PasswordRecoveryError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
@ -446,7 +480,7 @@ public func performPasswordRecovery(accountManager: AccountManager, account: Una
|
||||
|> mapError { _ -> PasswordRecoveryError in }
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public enum AccountResetError {
|
||||
case generic
|
||||
|
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 131
|
||||
return 130
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
@ -18,7 +18,7 @@ public func twoStepVerificationConfiguration(account: Account) -> Signal<TwoStep
|
||||
switch result {
|
||||
case let .password(password):
|
||||
if password.currentAlgo != nil {
|
||||
return .set(hint: password.hint ?? "", hasRecoveryEmail: (password.flags & (1 << 0)) != 0, pendingEmail: password.emailUnconfirmedPattern.flatMap({ TwoStepVerificationPendingEmail(pattern: $0, codeLength: nil) }), hasSecureValues: (password.flags & (1 << 1)) != 0, pendingResetTimestamp: password.pendingResetDate)
|
||||
return .set(hint: password.hint ?? "", hasRecoveryEmail: (password.flags & (1 << 0)) != 0, pendingEmail: password.emailUnconfirmedPattern.flatMap({ TwoStepVerificationPendingEmail(pattern: $0, codeLength: nil) }), hasSecureValues: (password.flags & (1 << 1)) != 0, pendingResetTimestamp: nil/*password.pendingResetDate*/)
|
||||
} else {
|
||||
return .notSet(pendingEmail: password.emailUnconfirmedPattern.flatMap({ TwoStepVerificationPendingEmail(pattern: $0, codeLength: nil) }))
|
||||
}
|
||||
@ -345,7 +345,7 @@ public func recoverTwoStepVerificationPassword(network: Network, code: String) -
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
|
||||
return network.request(Api.functions.auth.recoverPassword(flags: 0, code: code, newSettings: nil), automaticFloodWait: false)
|
||||
return network.request(Api.functions.auth.recoverPassword(code: code), automaticFloodWait: false)
|
||||
|> mapError { error -> RecoverTwoStepVerificationPasswordError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT_") {
|
||||
return .limitExceeded
|
||||
@ -426,7 +426,7 @@ public enum RequestTwoStepPasswordResetResult {
|
||||
case error(reason: ErrorReason)
|
||||
}
|
||||
|
||||
public func requestTwoStepPasswordReset(network: Network) -> Signal<RequestTwoStepPasswordResetResult, NoError> {
|
||||
/*public func requestTwoStepPasswordReset(network: Network) -> Signal<RequestTwoStepPasswordResetResult, NoError> {
|
||||
return network.request(Api.functions.account.resetPassword(), automaticFloodWait: false)
|
||||
|> map { _ -> RequestTwoStepPasswordResetResult in
|
||||
return .done
|
||||
@ -462,4 +462,4 @@ public func declineTwoStepPasswordReset(network: Network) -> Signal<Never, NoErr
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
}*/
|
||||
|
@ -571,6 +571,30 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
||||
|
||||
controller?.inProgress = true
|
||||
|
||||
strongSelf.actionDisposable.set((performPasswordRecovery(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, code: code, syncContacts: syncContacts) |> deliverOnMainQueue).start(error: { error in
|
||||
Queue.mainQueue().async {
|
||||
if let strongSelf = self, let controller = controller {
|
||||
controller.inProgress = false
|
||||
|
||||
let text: String
|
||||
switch error {
|
||||
case .limitExceeded:
|
||||
text = strongSelf.presentationData.strings.LoginPassword_FloodError
|
||||
case .invalidCode:
|
||||
text = strongSelf.presentationData.strings.Login_InvalidCodeError
|
||||
case .expired:
|
||||
text = strongSelf.presentationData.strings.Login_CodeExpiredError
|
||||
case .generic:
|
||||
text = strongSelf.presentationData.strings.Login_UnknownError
|
||||
}
|
||||
|
||||
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?.inProgress = true
|
||||
|
||||
strongSelf.actionDisposable.set((checkPasswordRecoveryCode(network: strongSelf.account.network, code: code)
|
||||
|> deliverOnMainQueue).start(error: { error in
|
||||
guard let strongSelf = self, let controller = controller else {
|
||||
@ -603,7 +627,7 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
||||
}
|
||||
})
|
||||
strongSelf.setViewControllers(strongSelf.viewControllers + [setupController], animated: true)
|
||||
}))
|
||||
}))*/
|
||||
}
|
||||
controller.noAccess = { [weak self, weak controller] in
|
||||
if let strongSelf = self, let controller = controller {
|
||||
|
Loading…
x
Reference in New Issue
Block a user