diff --git a/backends/carp_webservices/lib/carp_auth/carp_auth_service.dart b/backends/carp_webservices/lib/carp_auth/carp_auth_service.dart index 68949620..ea71d3dc 100644 --- a/backends/carp_webservices/lib/carp_auth/carp_auth_service.dart +++ b/backends/carp_webservices/lib/carp_auth/carp_auth_service.dart @@ -172,6 +172,7 @@ class CarpAuthService { String? code; String? clientId = _authProperties?.clientId; String? redirectUri = _authProperties?.anonymousRedirectURI?.toString(); + uri = _constructAuthUri(uri); TokenResponse tokenResponse = await FlutterWebAuth2.authenticate( url: uri, @@ -182,6 +183,7 @@ class CarpAuthService { ), ).then((result) async { code = Uri.parse(result).queryParameters['code']; + if ((_currentUser == null || _currentUser!.isAuthenticated) && code != null) { return await FlutterAppAuth().token( @@ -237,6 +239,11 @@ class CarpAuthService { ); } + String _constructAuthUri(String uri) { + String secondPart = uri.split('action-token').last; + return '${authProperties.discoveryURL}/login-actions/action-token$secondPart'; + } + /// Authenticate to this CARP service using a [username] and [password]. /// /// The discovery URL in the [authProperties] is used to find the Identity Server.