-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #415 from kausaltech/wip/multitenant-auth-2
Add redirect callback for multi-tenant auth
- Loading branch information
Showing
4 changed files
with
58 additions
and
41 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
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
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { useCallback } from 'react'; | ||
import { signOut } from 'next-auth/react'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
import { signOut } from 'next-auth/react'; | ||
|
||
import { authIssuer } from '@/common/environment'; | ||
|
||
export function useHandleSignOut() { | ||
const router = useRouter(); | ||
|
||
return useCallback(() => { | ||
signOut({ redirect: false }); | ||
|
||
/** | ||
* Redirect to the Admin UI logout page so that the session can be cleared. | ||
* The user will be redirected back to the `next` query parameter. | ||
*/ | ||
signOut({ redirect: true }); | ||
return; | ||
// TODO: Make this use RP-initiated logout when KW backend supports it. | ||
// See reference implementation in nzc-data-studio | ||
router.push(`${authIssuer}/logout?next=${encodeURI(window.location.href)}`); | ||
}, [router]); | ||
} |
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