From 2d459b7945672d6ffb683adef09ac111dbc9b5e0 Mon Sep 17 00:00:00 2001 From: username Date: Thu, 7 Apr 2022 09:43:36 +0200 Subject: [PATCH] Moved default provider function to authenticate() --- SSO-Auth/Api/SSOController.cs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/SSO-Auth/Api/SSOController.cs b/SSO-Auth/Api/SSOController.cs index c46c973..614e5b7 100644 --- a/SSO-Auth/Api/SSOController.cs +++ b/SSO-Auth/Api/SSOController.cs @@ -313,13 +313,6 @@ public class SSOController : ControllerBase { var authenticationResult = await Authenticate(kvp.Value.Username, kvp.Value.Admin, config.EnableAuthorization, config.EnableAllFolders, kvp.Value.Folders.ToArray(), response) .ConfigureAwait(false); - if (config.DefaultProvider != "") - { - User user = null; - user = _userManager.GetUserByName(kvp.Value.Username); - user.AuthenticationProviderId = config.DefaultProvider; - await _userManager.UpdateUserAsync(user).ConfigureAwait(false); - } return Ok(authenticationResult); } } @@ -493,13 +486,6 @@ public class SSOController : ControllerBase var authenticationResult = await Authenticate(samlResponse.GetNameID(), isAdmin, config.EnableAuthorization, config.EnableAllFolders, folders.ToArray(), response) .ConfigureAwait(false); - if( config.DefaultProvider != "") - { - User user = null; - user = _userManager.GetUserByName(samlResponse.GetNameID()); - user.AuthenticationProviderId = config.DefaultProvider; - await _userManager.UpdateUserAsync(user).ConfigureAwait(false); - } return Ok(authenticationResult); } } @@ -563,6 +549,14 @@ public class SSOController : ControllerBase authRequest.DeviceId = authResponse.DeviceID; authRequest.DeviceName = authResponse.DeviceName; _logger.LogInformation("Auth request created..."); + if (config.DefaultProvider != "") + { + User user = null; + user = _userManager.GetUserByName(kvp.Value.Username); + user.AuthenticationProviderId = config.DefaultProvider; + await _userManager.UpdateUserAsync(user).ConfigureAwait(false); + _logger.LogInformation("Set default login provider to " + config.DefaultProvider); + } return await _sessionManager.AuthenticateDirect(authRequest).ConfigureAwait(false); }