Injecting now AuthenticationService
This commit is contained in:
parent
8b2a210269
commit
79d746a395
|
@ -15,9 +15,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
setupBankingUi()
|
||||
|
||||
let authenticationService = AuthenticationService()
|
||||
let authenticationService = setupBankingUi()
|
||||
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
|
@ -36,11 +34,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private func setupBankingUi() {
|
||||
private func setupBankingUi() -> AuthenticationService {
|
||||
let appDataFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
|
||||
?? Bundle.main.resourceURL?.absoluteString ?? ""
|
||||
|
||||
let persistence = CoreDataBankingPersistence()
|
||||
let authenticationService = AuthenticationService()
|
||||
self.persistence = persistence
|
||||
|
||||
let dataFolder = URL(fileURLWithPath: "data", isDirectory: true, relativeTo: URL(fileURLWithPath: appDataFolder))
|
||||
|
@ -48,6 +47,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
let presenter = BankingPresenterSwift(dataFolder: dataFolder, router: SwiftUiRouter(), webClient: UrlSessionWebClient(), persistence: persistence, transactionPartySearcher: persistence, bankIconFinder: SwiftBankIconFinder(), serializer: NoOpSerializer(), asyncRunner: DispatchQueueAsyncRunner())
|
||||
|
||||
DependencyInjector.register(dependency: presenter)
|
||||
DependencyInjector.register(dependency: authenticationService)
|
||||
|
||||
return authenticationService
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ struct AddAccountDialog: View {
|
|||
|
||||
@Inject private var presenter: BankingPresenterSwift
|
||||
|
||||
@Inject private var authenticationService: AuthenticationService
|
||||
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
|
@ -107,7 +109,6 @@ struct AddAccountDialog: View {
|
|||
DispatchQueue.main.async { // dispatch async as may EnterTanDialog is still displayed so dismiss() won't dismiss this view
|
||||
self.closeDialog()
|
||||
|
||||
let authenticationService = AuthenticationService()
|
||||
if self.presenter.allBanks.count == 1 && authenticationService.authenticationType == .none {
|
||||
|
||||
UIAlert("Secure data?", "Secure data with password or %@?".localize(authenticationService.supportedBiometricAuthenticationLocalizedName),
|
||||
|
|
|
@ -19,7 +19,7 @@ struct LoginDialog: View {
|
|||
private let needsTouchIDToUnlockApp: Bool
|
||||
|
||||
|
||||
init(_ authenticationService: AuthenticationService = AuthenticationService(), allowCancellingLogin: Bool = false, loginReason: LocalizedStringKey? = nil, loginResult: @escaping (Bool) -> Void) {
|
||||
init(_ authenticationService: AuthenticationService, allowCancellingLogin: Bool = false, loginReason: LocalizedStringKey? = nil, loginResult: @escaping (Bool) -> Void) {
|
||||
|
||||
self.authenticationService = authenticationService
|
||||
self.allowCancellingLogin = allowCancellingLogin
|
||||
|
@ -130,7 +130,7 @@ struct LoginDialog: View {
|
|||
struct LoginDialog_Previews: PreviewProvider {
|
||||
|
||||
static var previews: some View {
|
||||
LoginDialog { _ in }
|
||||
LoginDialog(AuthenticationService()) { _ in }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ struct ProtectAppSettingsDialog: View {
|
|||
|
||||
@Environment(\.presentationMode) var presentation
|
||||
|
||||
@Inject private var authenticationService: AuthenticationService
|
||||
|
||||
private let authenticationService = AuthenticationService()
|
||||
|
||||
private var supportedAuthenticationTypes: [AuthenticationType] = []
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ struct SettingsDialog: View {
|
|||
|
||||
@Inject var presenter: BankingPresenterSwift
|
||||
|
||||
@Inject private var authenticationService: AuthenticationService
|
||||
|
||||
|
||||
@State private var updateAccountsAutomatically: Bool = true
|
||||
|
||||
|
@ -116,8 +118,6 @@ struct SettingsDialog: View {
|
|||
|
||||
|
||||
private func navigateToProtectAppSettingsDialog() {
|
||||
let authenticationService = AuthenticationService()
|
||||
|
||||
if authenticationService.needsAuthenticationToUnlockApp == false {
|
||||
SceneDelegate.navigateToView(ProtectAppSettingsDialog())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue