From dba033711dd3a0b020a0c4178b96bccdfb9f0e52 Mon Sep 17 00:00:00 2001 From: darth-coder00 <86726556+darth-coder00@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:32:27 +0530 Subject: [PATCH] Skip signin page if auth config is empty (#33) * Fixing behaviour for secure and non-secure mode * Adding swagger html to prettier ignore files --- catalog-rest-service/src/main/resources/ui/.prettierignore | 5 +++++ .../main/resources/ui/src/auth-provider/AuthProvider.tsx | 7 +++++-- .../src/main/resources/ui/src/pages/signup/index.tsx | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/catalog-rest-service/src/main/resources/ui/.prettierignore b/catalog-rest-service/src/main/resources/ui/.prettierignore index 5a51d29066e..e45db894836 100644 --- a/catalog-rest-service/src/main/resources/ui/.prettierignore +++ b/catalog-rest-service/src/main/resources/ui/.prettierignore @@ -30,5 +30,10 @@ dist/ .prettierignore .eslintignore +# rc, json and html files +.prettierrc +.lintstagedrc.json +swagger.html + # macOS .DS_Store diff --git a/catalog-rest-service/src/main/resources/ui/src/auth-provider/AuthProvider.tsx b/catalog-rest-service/src/main/resources/ui/src/auth-provider/AuthProvider.tsx index c05b90ca496..b688aec90a9 100644 --- a/catalog-rest-service/src/main/resources/ui/src/auth-provider/AuthProvider.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/auth-provider/AuthProvider.tsx @@ -17,7 +17,7 @@ import { AxiosResponse } from 'axios'; import { CookieStorage } from 'cookie-storage'; -import { isEmpty } from 'lodash'; +import { isEmpty, isNil } from 'lodash'; import { observer } from 'mobx-react'; import { User } from 'Models'; import { UserManager, WebStorageStateStore } from 'oidc-client'; @@ -155,7 +155,10 @@ const AuthProvider: FunctionComponent = ({ const fetchAuthConfig = (): void => { fetchAuthorizerConfig() .then((res: AxiosResponse) => { - if (res.data) { + const isSecureMode = + !isNil(res.data) && + Object.values(res.data).filter((item) => isNil(item)).length === 0; + if (isSecureMode) { const { provider, authority, clientId, callbackUrl } = res.data; const userConfig = getUserManagerConfig({ authority, diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/signup/index.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/signup/index.tsx index 7d8e8180652..5e919650514 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/signup/index.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/pages/signup/index.tsx @@ -100,7 +100,7 @@ const Signup = () => { ...details, teams: selectedTeams as Array, profile: { - images: getImages(appState.newUser.picture), + images: getImages(appState.newUser.picture ?? ''), }, }); }