Skip to content

Commit

Permalink
Merge pull request #1365 from nickgros/fix-dev-cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros authored Nov 12, 2024
2 parents e93815e + 243e016 commit 76e844a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SparkMD5 from 'spark-md5'
import UniversalCookies from 'universal-cookie'
import {
ACCESS_TOKEN_COOKIE_KEY,
getCookieDomain,
OAuth2State,
SynapseConstants,
} from '../utils'
Expand Down Expand Up @@ -1975,6 +1976,7 @@ export const setAccessTokenCookie = async (
// expires in 10 days (see SWC-6190)
maxAge: 60 * 60 * 24 * 10,
path: '/',
domain: getCookieDomain(),
})
}
} else {
Expand Down
10 changes: 7 additions & 3 deletions packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ export const ONE_SAGE_REDIRECT_COOKIE_KEY =
'org.sagebionetworks.cookies.redirect-after-login'

export const getCookieDomain = () => {
return window.location.hostname.toLowerCase().endsWith('.synapse.org')
? '.synapse.org'
: undefined
if (window.location.hostname.toLowerCase().endsWith('.synapse.org')) {
return '.synapse.org'
}
if (window.location.hostname.toLowerCase().endsWith('.dev.sagebase.org')) {
return '.dev.sagebase.org'
}
return undefined
}

export function storeRedirectURLForOneSageLoginAndGotoURL(href: string) {
Expand Down

0 comments on commit 76e844a

Please sign in to comment.