Fix PR remarks

This commit is contained in:
ismailgulek
2022-05-30 19:56:23 +03:00
parent 18a8bf53a5
commit 11d743a03e
12 changed files with 119 additions and 82 deletions
@@ -137,8 +137,10 @@ class AuthenticationService: NSObject {
func reset() {
loginWizard = nil
registrationWizard = nil
self.state = AuthenticationState(flow: .login, homeserverAddress: state.homeserver.address)
// The previously used homeserver is re-used as `startFlow` will be called again a replace it anyway.
let address = state.homeserver.addressFromUser ?? state.homeserver.address
self.state = AuthenticationState(flow: .login, homeserverAddress: address)
}
/// Continues an SSO flow when completion comes via a deep link.
@@ -63,18 +63,17 @@ struct AuthenticationState {
AuthenticationHomeserverViewData(address: displayableAddress,
isMatrixDotOrg: isMatrixDotOrg,
showLoginForm: preferredLoginMode.supportsPasswordFlow,
showRegistrationForm: registrationFlow != nil,
showRegistrationForm: registrationFlow != nil && !needsRegistrationFallback,
ssoIdentityProviders: preferredLoginMode.ssoIdentityProviders ?? [])
}
/// Needs authentication fallback for login or registration
var needsFallback: Bool {
switch preferredLoginMode {
case .unsupported:
return true
default:
break
}
/// Needs authentication fallback for login
var needsLoginFallback: Bool {
return preferredLoginMode.isUnsupported
}
/// Needs authentication fallback for registration
var needsRegistrationFallback: Bool {
guard let flow = registrationFlow else {
return false
}
@@ -75,6 +75,15 @@ enum LoginMode {
return false
}
}
var isUnsupported: Bool {
switch self {
case .unsupported:
return true
default:
return false
}
}
}
/// Data obtained when calling `LoginWizard.resetPassword` that will be used