mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-26 11:39:00 +00:00
Open the sign-up page when creating an account with OAuth
Create account sent prompt=consent, the same as Sign in, so MAS opened its sign-in page and new users were asked for a password they didn't have. The create prompt was turned off because MAS used to sign you straight into an existing browser session (element-hq/matrix-authentication-service#3429). MAS v0.15.0 fixed that by always showing its consent page, so send prompt=create again for registration, but only when the server advertises it.
This commit is contained in:
@@ -116,10 +116,10 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
|||||||
func urlForOAuthLogin(loginHint: String?) async -> Result<OAuthAuthorizationDataProxy, AuthenticationServiceError> {
|
func urlForOAuthLogin(loginHint: String?) async -> Result<OAuthAuthorizationDataProxy, AuthenticationServiceError> {
|
||||||
guard let client else { return .failure(.oAuthError(.urlFailure)) }
|
guard let client else { return .failure(.oAuthError(.urlFailure)) }
|
||||||
do {
|
do {
|
||||||
// The create prompt is broken: https://github.com/element-hq/matrix-authentication-service/issues/3429
|
let supportsCreatePrompt = homeserverSubject.value.loginMode == .oAuth(supportsCreatePrompt: true)
|
||||||
// let prompt: OAuthPrompt = flow == .register ? .create : .consent
|
let prompt: OAuthPrompt = flow == .register && supportsCreatePrompt ? .create : .consent
|
||||||
let oAuthData = try await client.urlForOauth(oauthConfiguration: appSettings.oAuthConfiguration.rustValue,
|
let oAuthData = try await client.urlForOauth(oauthConfiguration: appSettings.oAuthConfiguration.rustValue,
|
||||||
prompt: .consent,
|
prompt: prompt,
|
||||||
loginHint: loginHint,
|
loginHint: loginHint,
|
||||||
deviceId: nil,
|
deviceId: nil,
|
||||||
additionalScopes: nil)
|
additionalScopes: nil)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
@testable import ElementX
|
@testable import ElementX
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import MatrixRustSDK
|
||||||
import MatrixRustSDKMocks
|
import MatrixRustSDKMocks
|
||||||
import Testing
|
import Testing
|
||||||
|
|
||||||
@@ -77,6 +78,18 @@ struct AuthenticationServiceTests {
|
|||||||
loginMode: .unknown))
|
loginMode: .unknown))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(arguments: [("matrix.org", AuthenticationFlow.login, OAuthPrompt.consent),
|
||||||
|
("matrix.org", .register, .create),
|
||||||
|
("company.com", .register, .consent)])
|
||||||
|
mutating func oAuthPrompt(serverName: String, flow: AuthenticationFlow, expectedPrompt: OAuthPrompt) async throws {
|
||||||
|
try await setup(serverNameOrBaseURL: serverName)
|
||||||
|
try await service.configure(for: serverName, flow: flow).get()
|
||||||
|
|
||||||
|
_ = try await service.urlForOAuthLogin(loginHint: nil).get()
|
||||||
|
|
||||||
|
#expect(client.urlForOauthOauthConfigurationPromptLoginHintDeviceIdAdditionalScopesReceivedArguments?.prompt == expectedPrompt)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
mutating func classicAppAccountSecretsBundleIsUsed() async throws {
|
mutating func classicAppAccountSecretsBundleIsUsed() async throws {
|
||||||
// Given an authentication service with an Element Classic account for Alice.
|
// Given an authentication service with an Element Classic account for Alice.
|
||||||
|
|||||||
Reference in New Issue
Block a user