-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate sso from auth context, rename context
- Loading branch information
1 parent
b025343
commit 7be48d4
Showing
19 changed files
with
81 additions
and
82 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
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
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
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,32 +1,28 @@ | ||
import usePimsUser, { IPimsUser } from '@/hooks/usePimsUser'; | ||
import { AuthService, useSSO } from '@bcgov/citz-imb-sso-react'; | ||
import usePimsUser, { IPimsUser as PimsUser } from '@/hooks/usePimsUser'; | ||
import React, { createContext } from 'react'; | ||
export interface IAuthState { | ||
keycloak: AuthService; | ||
pimsUser: IPimsUser; | ||
export interface PimsUserState { | ||
pimsUser: PimsUser; | ||
} | ||
export const AuthContext = createContext<IAuthState | undefined>(undefined); | ||
export const UserContext = createContext<PimsUserState | undefined>(undefined); | ||
|
||
/** | ||
* Provides access to user and authentication (keycloak) data about the logged in user. | ||
* Provides access to user data about the logged in user. | ||
* | ||
* @param {*} props | ||
* @return {*} | ||
*/ | ||
export const AuthContextProvider: React.FC<React.PropsWithChildren> = (props) => { | ||
const keycloak = useSSO(); | ||
export const UserContextProvider: React.FC<React.PropsWithChildren> = (props) => { | ||
const pimsUser = usePimsUser(); | ||
|
||
return ( | ||
<AuthContext.Provider | ||
<UserContext.Provider | ||
value={{ | ||
keycloak, | ||
pimsUser, | ||
}} | ||
> | ||
{props.children} | ||
</AuthContext.Provider> | ||
</UserContext.Provider> | ||
); | ||
}; | ||
|
||
export default AuthContextProvider; | ||
export default UserContextProvider; |
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
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
Oops, something went wrong.