Login: remove get sso if type oauth

This commit is contained in:
Timofey Boyko 2023-11-17 14:20:44 +03:00
parent 61ae9c1a72
commit 6e3b5d0338
2 changed files with 16 additions and 40 deletions

View File

@ -44,16 +44,18 @@ app.use(
}) })
); );
app.use(logger("dev", { app.use(
logger("dev", {
stream: stream, stream: stream,
skip: function (req, res) { skip: function (req, res) {
if (req.url == '/health') { if (req.url == "/health") {
return true; return true;
} else { } else {
return false; return false;
} }
} },
})); })
);
app.get("*", async (req: ILoginRequest, res: Response, next) => { app.get("*", async (req: ILoginRequest, res: Response, next) => {
const { i18n, cookies, headers, query, t, url } = req; const { i18n, cookies, headers, query, t, url } = req;
@ -79,7 +81,7 @@ app.get("*", async (req: ILoginRequest, res: Response, next) => {
return next(); return next();
} }
initialState = await getInitialState(query); initialState = await getInitialState(query, isAuth);
const hideAuthPage = initialState?.ssoSettings?.hideAuthPage; const hideAuthPage = initialState?.ssoSettings?.hideAuthPage;
const ssoUrl = initialState?.capabilities?.ssoUrl; const ssoUrl = initialState?.capabilities?.ssoUrl;

View File

@ -15,7 +15,6 @@ import { checkIsAuthenticated } from "@docspace/common/api/user";
import { getClient, getScopeList } from "@docspace/common/api/oauth"; import { getClient, getScopeList } from "@docspace/common/api/oauth";
import { TenantStatus } from "@docspace/common/constants"; import { TenantStatus } from "@docspace/common/constants";
import { IScope } from "@docspace/common/utils/oauth/interfaces"; import { IScope } from "@docspace/common/utils/oauth/interfaces";
import winston, { stream } from "../logger";
export const getAssets = (): assetsType => { export const getAssets = (): assetsType => {
const manifest = fs.readFileSync( const manifest = fs.readFileSync(
@ -49,7 +48,8 @@ export const loadPath = (language: string, nameSpace: string): string => {
}; };
export const getInitialState = async ( export const getInitialState = async (
query: MatchType query: MatchType,
isAuth: boolean
): Promise<IInitialState> => { ): Promise<IInitialState> => {
let portalSettings: IPortalSettings, let portalSettings: IPortalSettings,
buildInfo: IBuildInfo, buildInfo: IBuildInfo,
@ -66,11 +66,9 @@ export const getInitialState = async (
getLogoUrls(), getLogoUrls(),
]; ];
const settings = [ const settings = [getAuthProviders(), getCapabilities()];
getAuthProviders(),
getCapabilities(), if (!isAuth) settings.push(getCurrentSsoSettings());
// getCurrentSsoSettings(),
];
[portalSettings, buildInfo, availableThemes, logoUrls] = await Promise.all( [portalSettings, buildInfo, availableThemes, logoUrls] = await Promise.all(
baseSettings baseSettings
@ -104,30 +102,6 @@ export const getOAuthState = async (
): Promise<IOAuthState> => { ): Promise<IOAuthState> => {
const requests = []; const requests = [];
try {
await getClient(clientId, isAuth);
} catch (e) {
console.log("get client");
console.log(e);
winston.error(e);
}
try {
await getUser();
} catch (e) {
console.log("get user");
console.log(e);
winston.error(e);
}
try {
await getScopeList();
} catch (e) {
console.log("get scopes");
console.log(e);
winston.error(e);
}
requests.push(getClient(clientId, isAuth)); requests.push(getClient(clientId, isAuth));
if (isAuth) { if (isAuth) {