mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add option to disable future login tokens
This commit is contained in:
parent
ff09220634
commit
8876026edb
@ -192,13 +192,15 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
return
|
||||
}
|
||||
controller?.inProgress = true
|
||||
|
||||
let disableAuthTokens = self.sharedContext.immediateExperimentalUISettings.disableReloginTokens
|
||||
let authorizationPushConfiguration = self.sharedContext.authorizationPushConfiguration
|
||||
|> take(1)
|
||||
|> timeout(2.0, queue: .mainQueue(), alternate: .single(nil))
|
||||
let _ = (authorizationPushConfiguration
|
||||
|> deliverOnMainQueue).startStandalone(next: { [weak self] authorizationPushConfiguration in
|
||||
if let strongSelf = self {
|
||||
strongSelf.actionDisposable.set((sendAuthorizationCode(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, phoneNumber: number, apiId: strongSelf.apiId, apiHash: strongSelf.apiHash, pushNotificationConfiguration: authorizationPushConfiguration, firebaseSecretStream: strongSelf.sharedContext.firebaseSecretStream, syncContacts: syncContacts, forcedPasswordSetupNotice: { value in
|
||||
strongSelf.actionDisposable.set((sendAuthorizationCode(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, phoneNumber: number, apiId: strongSelf.apiId, apiHash: strongSelf.apiHash, pushNotificationConfiguration: authorizationPushConfiguration, firebaseSecretStream: strongSelf.sharedContext.firebaseSecretStream, syncContacts: syncContacts, disableAuthTokens: disableAuthTokens, forcedPasswordSetupNotice: { value in
|
||||
guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else {
|
||||
return nil
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
case storiesJpegExperiment(Bool)
|
||||
case playlistPlayback(Bool)
|
||||
case enableQuickReactionSwitch(Bool)
|
||||
case disableReloginTokens(Bool)
|
||||
case voiceConference
|
||||
case preferredVideoCodec(Int, String, String?, Bool)
|
||||
case disableVideoAspectScaling(Bool)
|
||||
@ -126,7 +127,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
return DebugControllerSection.web.rawValue
|
||||
case .keepChatNavigationStack, .skipReadHistory, .dustEffect, .crashOnSlowQueries, .crashOnMemoryPressure:
|
||||
return DebugControllerSection.experiments.rawValue
|
||||
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .voiceConference, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases:
|
||||
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .voiceConference, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens:
|
||||
return DebugControllerSection.experiments.rawValue
|
||||
case .logTranslationRecognition, .resetTranslationStates:
|
||||
return DebugControllerSection.translation.rawValue
|
||||
@ -233,14 +234,16 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
return 46
|
||||
case .storiesJpegExperiment:
|
||||
return 47
|
||||
case .playlistPlayback:
|
||||
case .disableReloginTokens:
|
||||
return 48
|
||||
case .enableQuickReactionSwitch:
|
||||
case .playlistPlayback:
|
||||
return 49
|
||||
case .voiceConference:
|
||||
case .enableQuickReactionSwitch:
|
||||
return 50
|
||||
case .voiceConference:
|
||||
return 51
|
||||
case let .preferredVideoCodec(index, _, _, _):
|
||||
return 51 + index
|
||||
return 52 + index
|
||||
case .disableVideoAspectScaling:
|
||||
return 100
|
||||
case .enableNetworkFramework:
|
||||
@ -1371,6 +1374,14 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
}
|
||||
})
|
||||
})
|
||||
case let .disableReloginTokens(value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: "Disable Relogin Tokens", value: value, sectionId: self.section, style: .blocks, updated: { value in
|
||||
let _ = updateExperimentalUISettingsInteractively(accountManager: arguments.sharedContext.accountManager, { settings in
|
||||
var settings = settings
|
||||
settings.disableReloginTokens = value
|
||||
return settings
|
||||
}).start()
|
||||
})
|
||||
case let .hostInfo(_, string):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(string), sectionId: self.section)
|
||||
case .versionInfo:
|
||||
@ -1449,10 +1460,11 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
||||
|
||||
entries.append(.logTranslationRecognition(experimentalSettings.logLanguageRecognition))
|
||||
entries.append(.resetTranslationStates)
|
||||
|
||||
|
||||
if case .internal = sharedContext.applicationBindings.appBuildType {
|
||||
entries.append(.storiesExperiment(experimentalSettings.storiesExperiment))
|
||||
entries.append(.storiesJpegExperiment(experimentalSettings.storiesJpegExperiment))
|
||||
entries.append(.disableReloginTokens(experimentalSettings.disableReloginTokens))
|
||||
}
|
||||
entries.append(.playlistPlayback(experimentalSettings.playlistPlayback))
|
||||
entries.append(.enableQuickReactionSwitch(!experimentalSettings.disableQuickReaction))
|
||||
|
@ -142,7 +142,7 @@ private func sendFirebaseAuthorizationCode(accountManager: AccountManager<Telegr
|
||||
}
|
||||
}
|
||||
|
||||
public func sendAuthorizationCode(accountManager: AccountManager<TelegramAccountManagerTypes>, account: UnauthorizedAccount, phoneNumber: String, apiId: Int32, apiHash: String, pushNotificationConfiguration: AuthorizationCodePushNotificationConfiguration?, firebaseSecretStream: Signal<[String: String], NoError>, syncContacts: Bool, forcedPasswordSetupNotice: @escaping (Int32) -> (NoticeEntryKey, CodableEntry)?) -> Signal<SendAuthorizationCodeResult, AuthorizationCodeRequestError> {
|
||||
public func sendAuthorizationCode(accountManager: AccountManager<TelegramAccountManagerTypes>, account: UnauthorizedAccount, phoneNumber: String, apiId: Int32, apiHash: String, pushNotificationConfiguration: AuthorizationCodePushNotificationConfiguration?, firebaseSecretStream: Signal<[String: String], NoError>, syncContacts: Bool, disableAuthTokens: Bool = false, forcedPasswordSetupNotice: @escaping (Int32) -> (NoticeEntryKey, CodableEntry)?) -> Signal<SendAuthorizationCodeResult, AuthorizationCodeRequestError> {
|
||||
var cloudValue: [Data] = []
|
||||
if let list = NSUbiquitousKeyValueStore.default.object(forKey: "T_SLTokens") as? [String] {
|
||||
cloudValue = list.compactMap { string -> Data? in
|
||||
@ -152,9 +152,6 @@ public func sendAuthorizationCode(accountManager: AccountManager<TelegramAccount
|
||||
return Data(base64Encoded: stringData)
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
cloudValue.removeAll()
|
||||
#endif
|
||||
return accountManager.transaction { transaction -> [Data] in
|
||||
return transaction.getStoredLoginTokens()
|
||||
}
|
||||
@ -162,16 +159,20 @@ public func sendAuthorizationCode(accountManager: AccountManager<TelegramAccount
|
||||
|> mapToSignal { localAuthTokens -> Signal<SendAuthorizationCodeResult, AuthorizationCodeRequestError> in
|
||||
var authTokens = localAuthTokens
|
||||
|
||||
#if DEBUG
|
||||
authTokens.removeAll()
|
||||
#endif
|
||||
|
||||
for data in cloudValue {
|
||||
if !authTokens.contains(data) {
|
||||
authTokens.insert(data, at: 0)
|
||||
}
|
||||
}
|
||||
|
||||
if disableAuthTokens {
|
||||
authTokens.removeAll()
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
authTokens.removeAll()
|
||||
#endif
|
||||
|
||||
var flags: Int32 = 0
|
||||
flags |= 1 << 5 //allowMissedCall
|
||||
flags |= 1 << 6 //tokens
|
||||
|
@ -56,6 +56,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
public var dustEffect: Bool
|
||||
public var callV2: Bool
|
||||
public var allowWebViewInspection: Bool
|
||||
public var disableReloginTokens: Bool
|
||||
|
||||
public static var defaultSettings: ExperimentalUISettings {
|
||||
return ExperimentalUISettings(
|
||||
@ -89,7 +90,8 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
crashOnMemoryPressure: false,
|
||||
dustEffect: false,
|
||||
callV2: false,
|
||||
allowWebViewInspection: false
|
||||
allowWebViewInspection: false,
|
||||
disableReloginTokens: false
|
||||
)
|
||||
}
|
||||
|
||||
@ -124,7 +126,8 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
crashOnMemoryPressure: Bool,
|
||||
dustEffect: Bool,
|
||||
callV2: Bool,
|
||||
allowWebViewInspection: Bool
|
||||
allowWebViewInspection: Bool,
|
||||
disableReloginTokens: Bool
|
||||
) {
|
||||
self.keepChatNavigationStack = keepChatNavigationStack
|
||||
self.skipReadHistory = skipReadHistory
|
||||
@ -157,6 +160,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
self.dustEffect = dustEffect
|
||||
self.callV2 = callV2
|
||||
self.allowWebViewInspection = allowWebViewInspection
|
||||
self.disableReloginTokens = disableReloginTokens
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -193,6 +197,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
self.dustEffect = try container.decodeIfPresent(Bool.self, forKey: "dustEffect") ?? false
|
||||
self.callV2 = try container.decodeIfPresent(Bool.self, forKey: "callV2") ?? false
|
||||
self.allowWebViewInspection = try container.decodeIfPresent(Bool.self, forKey: "allowWebViewInspection") ?? false
|
||||
self.disableReloginTokens = try container.decodeIfPresent(Bool.self, forKey: "disableReloginTokens") ?? false
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -229,6 +234,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
try container.encode(self.dustEffect, forKey: "dustEffect")
|
||||
try container.encode(self.callV2, forKey: "callV2")
|
||||
try container.encode(self.allowWebViewInspection, forKey: "allowWebViewInspection")
|
||||
try container.encode(self.disableReloginTokens, forKey: "disableReloginTokens")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user