From 7991b3a157e021bbcc8ede838d66b0c34e290e71 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Wed, 16 Feb 2022 19:04:32 +0700 Subject: [PATCH] fix(#2227): fix redirect url for localhost --- src/features/AuthServiceApp/requests/auth.tsx | 4 ++-- src/features/AuthStore/helpers.tsx | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/features/AuthServiceApp/requests/auth.tsx b/src/features/AuthServiceApp/requests/auth.tsx index 1f2be78b..531b5e22 100644 --- a/src/features/AuthServiceApp/requests/auth.tsx +++ b/src/features/AuthServiceApp/requests/auth.tsx @@ -24,7 +24,7 @@ export const loginCheck = async ( email: string, lang: string, password: string, - redirect_uri: string | undefined, + currentRedirectUrl: string | undefined, ) => { const { client_id, @@ -36,7 +36,7 @@ export const loginCheck = async ( const paramsUrl = { client_id, lang, - redirect_uri, + redirect_uri: currentRedirectUrl, response_mode, response_type, scope, diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index e11b0956..997f5ca3 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -6,6 +6,16 @@ import { AUTH_SERVICE } from 'config/routes' import { ENV } from 'config/env' +const redirectUrl = () => { + if (process.env.NODE_ENV === 'development') { + return `${window.origin}/redirect` + } + if (ENV === 'staging') { + return `https://${ENV}.${client.name}.tv/redirect` + } + return `https://${client.name}.tv/redirect` +} + export const getClientSettings = (): UserManagerSettings => ({ authority: AUTH_SERVICE, automaticSilentRenew: true, @@ -13,7 +23,7 @@ export const getClientSettings = (): UserManagerSettings => ({ filterProtocolClaims: false, loadUserInfo: false, metadataUrl: `${AUTH_SERVICE}/.well-known/openid-configuration${client.auth.metaDataUrlParams || ''}`, - redirect_uri: ENV === 'staging' ? `https://${ENV}.${client.name}.tv/redirect` : `https://${client.name}.tv/redirect`, + redirect_uri: redirectUrl(), response_mode: 'query', response_type: 'id_token token', scope: 'openid',