Skip to content

Commit

Permalink
fix(client): reload after login/logout when url contains hash (#1298)
Browse files Browse the repository at this point in the history
Co-authored-by: Thew Dhanat
  • Loading branch information
balazsorban44 committed Feb 11, 2021
1 parent 61047e3 commit 6e28a07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/header.js
Expand Up @@ -54,7 +54,7 @@ export default function Header () {
className={styles.button}
onClick={(e) => {
e.preventDefault()
signOut({ redirect: false })
signOut()
}}
>
Sign out
Expand Down
11 changes: 9 additions & 2 deletions src/client/index.js
Expand Up @@ -278,7 +278,11 @@ export async function signIn (provider, options = {}, authorizationParams = {})
const res = await fetch(_signInUrl, fetchOptions)
const data = await res.json()
if (redirect || !isCredentials) {
window.location = data.url ?? callbackUrl
const url = data.url ?? callbackUrl
window.location = url
// If url contains a hash, the browser does not reload the page. We reload manually
if (url.includes('#')) window.location.reload()

return
}

Expand Down Expand Up @@ -324,7 +328,10 @@ export async function signOut (options = {}) {
const data = await res.json()
_sendMessage({ event: 'session', data: { trigger: 'signout' } })
if (redirect) {
window.location = data.url ?? callbackUrl
const url = data.url ?? callbackUrl
window.location = url
// If url contains a hash, the browser does not reload the page. We reload manually
if (url.includes('#')) window.location.reload()
return
}

Expand Down

1 comment on commit 6e28a07

@vercel
Copy link

@vercel vercel bot commented on 6e28a07 Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.