From e1785d4d16bbde5e1f237970985e925ddc727693 Mon Sep 17 00:00:00 2001 From: Randy Woods Date: Tue, 6 Feb 2024 12:57:14 -0700 Subject: [PATCH] Reports weren't being informed of the user's language The StandAlone API call was returning null if the installation was NOT standalone. But that response should contain the current user's language. Now, if there is a current user, a proper response is returned. --- .../CSETWebCore.Helpers/UserAuthentication.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/UserAuthentication.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/UserAuthentication.cs index a517759391..8bc730cbd9 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/UserAuthentication.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/UserAuthentication.cs @@ -168,6 +168,29 @@ public LoginResponse AuthenticateStandalone(Login login, ITokenManager tokenMana // Read the file system for the LOCAL-INSTALLATION file put there at install time if (!_localInstallationHelper.IsLocalInstallation()) { + // this is not a local install. Return what we know about this user. + var loginUser = _context.USERS.Where(x => x.UserId == int.Parse(tokenManager.Payload("userid"))).FirstOrDefault(); + + if (loginUser != null) + { + var respUser = new LoginResponse + { + UserId = loginUser.UserId, + Email = login.Email, + Lang = loginUser.Lang, + UserFirstName = loginUser.FirstName, + UserLastName = loginUser.LastName, + IsSuperUser = loginUser.IsSuperUser, + ResetRequired = loginUser.PasswordResetRequired ?? true, + ExportExtension = IOHelper.GetExportFileExtension(login.Scope), + ImportExtensions = IOHelper.GetImportFileExtensions(login.Scope), + LinkerTime = new BuildNumberHelper().GetLinkerTime(), + IsFirstLogin = loginUser.IsFirstLogin ?? false + }; + + return respUser; + } + return null; } @@ -237,7 +260,7 @@ public LoginResponse AuthenticateStandalone(Login login, ITokenManager tokenMana string token = _transactionSecurity.GenerateToken(userIdSO, null, login.TzOffset, -1, assessmentId, null, login.Scope); // Build response object - LoginResponse resp = new LoginResponse + var resp = new LoginResponse { Token = token, Email = primaryEmailSO,