mirror of
https://github.com/twofas/2fas-ios.git
synced 2024-11-25 03:40:26 +01:00
v5.3.0/TF-1506 Adding info about incorrect code when scanning using system camera
This commit is contained in:
parent
d321f7967d
commit
bccaf26810
@ -23,6 +23,7 @@ import Common
|
||||
public protocol LinkInteracting: AnyObject {
|
||||
var hasStoredURL: Bool { get }
|
||||
var showCodeAlreadyExists: Callback? { get set }
|
||||
var showIncorrectCode: Callback? { get set }
|
||||
var showShouldAddCode: ((String?) -> Void)? { get set }
|
||||
var showSendLogs: ((UUID) -> Void)? { get set }
|
||||
var reloadDataAndRefresh: Callback? { get set }
|
||||
@ -43,6 +44,7 @@ final class LinkInteractor {
|
||||
private let interactorNew: NewCodeInteracting
|
||||
|
||||
var showCodeAlreadyExists: Callback?
|
||||
var showIncorrectCode: Callback?
|
||||
var showShouldAddCode: ((String?) -> Void)?
|
||||
var showSendLogs: ((UUID) -> Void)?
|
||||
var reloadDataAndRefresh: Callback?
|
||||
@ -68,6 +70,7 @@ extension LinkInteractor: LinkInteracting {
|
||||
Log("URL: \(url)", module: .interactor, save: false)
|
||||
|
||||
guard mainRepository.shouldHandleURL(url) else {
|
||||
mainRepository.saveHasIncorrectCode()
|
||||
Log("LinkInteractor - shouldHandleURL - won't handle", module: .interactor)
|
||||
return false
|
||||
}
|
||||
@ -80,6 +83,11 @@ extension LinkInteractor: LinkInteracting {
|
||||
Log("LinkInteractor - handleCodeIfNecessary", module: .interactor)
|
||||
guard hasStoredURL else {
|
||||
Log("LinkInteractor - handleCodeIfNecessary - no url", module: .interactor)
|
||||
if mainRepository.hasIncorrectCode {
|
||||
Log("LinkInteractor - hasIncorrectCode", module: .interactor)
|
||||
mainRepository.clearHasIncorrectCode()
|
||||
showIncorrectCode?()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -101,6 +109,7 @@ extension LinkInteractor: LinkInteracting {
|
||||
default:
|
||||
Log("LinkInteractor - handleCodeIfNecessary - not supported type - exiting", module: .interactor)
|
||||
mainRepository.clearStoredURL()
|
||||
showIncorrectCode?()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -254,6 +254,9 @@ protocol MainRepository: AnyObject {
|
||||
func clearStoredURL()
|
||||
func codeFromStoredURL() -> Code?
|
||||
func codeTypeFromStoredURL() -> CodeType?
|
||||
var hasIncorrectCode: Bool { get }
|
||||
func clearHasIncorrectCode()
|
||||
func saveHasIncorrectCode()
|
||||
|
||||
// MARK: - Old controllers
|
||||
var security: SecurityProtocol { get }
|
||||
|
@ -48,4 +48,11 @@ extension MainRepositoryImpl {
|
||||
guard let url = storedURL else { return nil }
|
||||
return Code.parse(with: url.absoluteString)
|
||||
}
|
||||
|
||||
func clearHasIncorrectCode() {
|
||||
hasIncorrectCode = false
|
||||
}
|
||||
func saveHasIncorrectCode() {
|
||||
hasIncorrectCode = true
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ final class MainRepositoryImpl: MainRepository {
|
||||
}
|
||||
|
||||
var storedURL: URL?
|
||||
var hasIncorrectCode: Bool
|
||||
var fileURL: URL?
|
||||
var sslNetworkError = false
|
||||
var lastFetchedNewsTimestamp: Date?
|
||||
@ -160,7 +161,7 @@ final class MainRepositoryImpl: MainRepository {
|
||||
|
||||
storageRepository = storage.storageRepository
|
||||
timeVerificationController.log = { value in Log(value, module: .counter) }
|
||||
|
||||
hasIncorrectCode = false
|
||||
security.interactor = AppLockStateInteractor(mainRepository: self)
|
||||
MainRepositoryImpl._shared = self
|
||||
|
||||
|
@ -45,6 +45,7 @@ protocol TokensPlainFlowControlling: AnyObject {
|
||||
func toShowGallery()
|
||||
func toHelp()
|
||||
// MARK: Link actions
|
||||
func toIncorrectCode()
|
||||
func toDuplicatedCode(forceAdd: @escaping Callback, cancel: @escaping Callback)
|
||||
func toShowShouldAddCode(with descriptionText: String?)
|
||||
func toSendLogs(auditID: UUID)
|
||||
@ -258,6 +259,19 @@ extension TokensPlainFlowController: TokensPlainFlowControlling {
|
||||
mainSplitViewController.present(alert, animated: true)
|
||||
}
|
||||
|
||||
func toIncorrectCode() {
|
||||
guard let mainSplitViewController, mainSplitViewController.presentedViewController == nil else { return }
|
||||
|
||||
let alert = UIAlertController(
|
||||
title: T.Commons.warning,
|
||||
message: T.Tokens.thisQrCodeIsInavlid,
|
||||
preferredStyle: .alert
|
||||
)
|
||||
alert.addAction(UIAlertAction(title: T.Commons.cancel, style: .cancel, handler: { _ in }))
|
||||
|
||||
mainSplitViewController.present(alert, animated: true)
|
||||
}
|
||||
|
||||
func toSendLogs(auditID: UUID) {
|
||||
sendLogs(auditID: auditID)
|
||||
}
|
||||
|
@ -424,6 +424,7 @@ extension TokensModuleInteractor: TokensModuleInteracting {
|
||||
private extension TokensModuleInteractor {
|
||||
private func setupLinkInteractor() {
|
||||
linkInteractor.showCodeAlreadyExists = { [weak self] in self?.linkAction?(.codeAlreadyExists) }
|
||||
linkInteractor.showIncorrectCode = { [weak self] in self?.linkAction?(.incorrectCode) }
|
||||
linkInteractor.showShouldAddCode = { [weak self] in self?.linkAction?(.shouldAddCode(descriptionText: $0)) }
|
||||
linkInteractor.showSendLogs = { [weak self] in self?.linkAction?(.sendLogs(auditID: $0)) }
|
||||
linkInteractor.reloadDataAndRefresh = { [weak self] in self?.linkAction?(.newData) }
|
||||
|
@ -25,6 +25,7 @@ enum TokensLinkAction {
|
||||
case shouldAddCode(descriptionText: String?)
|
||||
case sendLogs(auditID: UUID)
|
||||
case newData
|
||||
case incorrectCode
|
||||
case shouldRename(currentName: String, secret: Secret)
|
||||
case serviceWasCreaded(serviceData: ServiceData)
|
||||
}
|
||||
|
@ -134,6 +134,8 @@ extension TokensPresenter {
|
||||
case .newData: handleNewData()
|
||||
case .shouldRename(let currentName, let secret):
|
||||
flowController.toShouldRenameService(currentName: currentName, secret: secret)
|
||||
case .incorrectCode:
|
||||
flowController.toIncorrectCode()
|
||||
case .serviceWasCreaded(let serviceData):
|
||||
reloadData()
|
||||
flowController.toServiceWasCreated(serviceData)
|
||||
|
Loading…
Reference in New Issue
Block a user