Skip to content

Commit

Permalink
update latest code
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Sep 18, 2023
1 parent 043c15e commit a0a1d1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/pages/Oauth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<span>
Time to sign-in is Expired, please{' '}
<a href={queryStringToObject(window.location.search)?.back_uri + ''}>go back</a> and try again.
Time to sign-in is Expired, please <a href={backUri}>go back</a> and try again.

Check warning

Code scanning / CodeQL

Client-side cross-site scripting Medium

Cross-site scripting vulnerability due to
user-provided value
.

Check warning

Code scanning / CodeQL

Client-side URL redirect Medium

Untrusted URL redirection depends on a
user-provided value
.
</span>
)
}

return data?.ui?.messages?.[0]?.text || data?.error?.reason || data?.error?.message || error?.message || error + ''
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Oauth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0a1d1c

Please sign in to comment.