-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useMe } from '@biscuits/client'; | ||
import { useEffect } from 'react'; | ||
|
||
/** | ||
* A stub page that just calls an API request. This will automatically trigger session | ||
* refresh if the user is logged in. This page is rendered in an iframe by other apps | ||
* on other origins to transparently keep the session alive without having to know | ||
* the refresh token, which is stored in this app's origin localStorage. | ||
*/ | ||
export function RefreshSessionPage() { | ||
const [data] = useMe(); | ||
const success = data.data?.me; | ||
useEffect(() => { | ||
if (window.top) { | ||
window.top.postMessage({ type: 'refresh-session', success }, '*'); | ||
} | ||
}, [success]); | ||
return null; | ||
} | ||
|
||
export default RefreshSessionPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters