From 8761dbd75b45fcf406fdc81d7b366528f429cbf5 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Sat, 4 May 2024 21:51:09 +0100 Subject: [PATCH] refactor: Update login page SSO message for clarity and consistency --- Accounts/src/Pages/Login.tsx | 4 +++- App/FeatureSet/Identity/API/SSO.ts | 38 ++++++++++++++++++------------ Dashboard/src/App.tsx | 11 ++++----- Dashboard/src/Pages/Init/Init.tsx | 1 - 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Accounts/src/Pages/Login.tsx b/Accounts/src/Pages/Login.tsx index 00299dafc3..8308772b7e 100644 --- a/Accounts/src/Pages/Login.tsx +++ b/Accounts/src/Pages/Login.tsx @@ -138,7 +138,9 @@ const LoginPage: () => JSX.Element = () => { {showSsoTip && (
- Please sign in with your SSO provider like Okta, Auth0, Entra ID or any other SAML 2.0 provider. + Please sign in with your SSO + provider like Okta, Auth0, Entra ID + or any other SAML 2.0 provider.
)} diff --git a/App/FeatureSet/Identity/API/SSO.ts b/App/FeatureSet/Identity/API/SSO.ts index a0c745f404..96c1705a41 100644 --- a/App/FeatureSet/Identity/API/SSO.ts +++ b/App/FeatureSet/Identity/API/SSO.ts @@ -123,7 +123,6 @@ const loginUserWithSso: LoginUserWithSsoFunction = async ( res: ExpressResponse ): Promise => { try { - debugger; const samlResponseBase64: string = req.body.SAMLResponse; @@ -383,7 +382,6 @@ const loginUserWithSso: LoginUserWithSsoFunction = async ( new PositiveNumber(30) ), }); - const oneUptimeToken: string = JSONWebToken.signUserLoginToken({ tokenData: { @@ -399,17 +397,29 @@ const loginUserWithSso: LoginUserWithSsoFunction = async ( }); // Set a cookie with token. - CookieUtil.setCookie(res, CookieUtil.getUserTokenKey(), oneUptimeToken, { - maxAge: OneUptimeDate.getMillisecondsInDays( - new PositiveNumber(30) - ), - httpOnly: true, - }); + CookieUtil.setCookie( + res, + CookieUtil.getUserTokenKey(), + oneUptimeToken, + { + maxAge: OneUptimeDate.getMillisecondsInDays( + new PositiveNumber(30) + ), + httpOnly: true, + } + ); - CookieUtil.setCookie(res, CookieUtil.getUserSSOKey(projectId), ssoToken, { - maxAge: OneUptimeDate.getMillisecondsInDays(new PositiveNumber(30)), - httpOnly: true, - }); + CookieUtil.setCookie( + res, + CookieUtil.getUserSSOKey(projectId), + ssoToken, + { + maxAge: OneUptimeDate.getMillisecondsInDays( + new PositiveNumber(30) + ), + httpOnly: true, + } + ); // Refresh Permissions for this user here. await AccessTokenService.refreshUserAllPermissions( @@ -419,7 +429,6 @@ const loginUserWithSso: LoginUserWithSsoFunction = async ( const host: Hostname = await DatabaseConfig.getHost(); const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol(); - return Response.redirect( req, res, @@ -428,10 +437,9 @@ const loginUserWithSso: LoginUserWithSsoFunction = async ( host, new Route(DashboardRoute.toString()).addRoute( '/' + req.params['projectId'] - ), + ) ) ); - } catch (err) { logger.error(err); Response.sendErrorResponse(req, res, new ServerException()); diff --git a/Dashboard/src/App.tsx b/Dashboard/src/App.tsx index d386ad446c..a22a978326 100644 --- a/Dashboard/src/App.tsx +++ b/Dashboard/src/App.tsx @@ -19,10 +19,7 @@ import Navigation from 'CommonUI/src/Utils/Navigation'; import RouteMap from './Utils/RouteMap'; import PageMap from './Utils/PageMap'; -import { - BILLING_ENABLED, - APP_API_URL, -} from 'CommonUI/src/Config'; +import { BILLING_ENABLED, APP_API_URL } from 'CommonUI/src/Config'; import ActiveIncidents from './Pages/Global/NewIncidents'; import ProjectInvitations from './Pages/Global/ProjectInvitations'; @@ -262,7 +259,7 @@ const App: () => JSX.Element = () => { {...commonPageProps} pageRoute={ RouteMap[ - PageMap.HOME_NOT_OPERATIONAL_MONITORS + PageMap.HOME_NOT_OPERATIONAL_MONITORS ] as Route } /> @@ -282,8 +279,8 @@ const App: () => JSX.Element = () => { {...commonPageProps} pageRoute={ RouteMap[ - PageMap - .HOME_ONGOING_SCHEDULED_MAINTENANCE_EVENTS + PageMap + .HOME_ONGOING_SCHEDULED_MAINTENANCE_EVENTS ] as Route } /> diff --git a/Dashboard/src/Pages/Init/Init.tsx b/Dashboard/src/Pages/Init/Init.tsx index 27d66a9a15..f2c3a9ef86 100644 --- a/Dashboard/src/Pages/Init/Init.tsx +++ b/Dashboard/src/Pages/Init/Init.tsx @@ -16,7 +16,6 @@ export interface ComponentProps extends PageComponentProps { const Init: FunctionComponent = ( props: ComponentProps ): ReactElement => { - useEffect(() => { // set slug to latest project and redirect to home.