diff --git a/src/pages/Oauth/Login.tsx b/src/pages/Oauth/Login.tsx index 9a830afabf..53a2ac6e9e 100644 --- a/src/pages/Oauth/Login.tsx +++ b/src/pages/Oauth/Login.tsx @@ -13,18 +13,20 @@ import { formatSignature } from 'utils/transaction' import AuthForm from './components/AuthForm' import { BUTTON_IDS } from './constants/index' -import { createSignMessage, getSupportLoginMethods } from './utils' +import { createSignMessage, getSupportLoginMethods, isValidRedirectURL } from './utils' const getErrorMsg = (error: any) => { const data = error?.response?.data const isExpired = data?.error?.id === 'self_service_flow_expired' - if (isExpired) + const backUri = queryStringToObject(window.location.search)?.back_uri + '' + if (isExpired && isValidRedirectURL(backUri)) { return ( - Time to sign-in is Expired, please{' '} - go back and try again. + Time to sign-in is Expired, please go back and try again. ) + } + return data?.ui?.messages?.[0]?.text || data?.error?.reason || data?.error?.message || error?.message || error + '' } diff --git a/src/pages/Oauth/utils.ts b/src/pages/Oauth/utils.ts index 00d67528c1..1d5bcdfaba 100644 --- a/src/pages/Oauth/utils.ts +++ b/src/pages/Oauth/utils.ts @@ -5,7 +5,7 @@ export const getSupportLoginMethods = (loginFlow: LoginFlow | undefined) => { } const whiteListDomains = [/https:\/\/(.+?\.)?kyberswap.com/, /https:\/\/(.+)\.kyberengineering.io/] -const isValidRedirectURL = (url: string | undefined) => { +export const isValidRedirectURL = (url: string | undefined) => { try { if (!url) return false const newUrl = new URL(url) // valid url