diff --git a/frontend/src/contexts/userContext.ts b/frontend/src/contexts/userContext.ts index 6fcc23f13aed02bfe0851de69151f29ae4cb38f8..ed0029453bb2f7ee438ed7338e42a8d442193dbe 100644 --- a/frontend/src/contexts/userContext.ts +++ b/frontend/src/contexts/userContext.ts @@ -12,6 +12,7 @@ function noop() {} export const UserContext = createContext<IUserContext>({ user: { auth: false, + auth_type: '', fetched: false, first_name: '', last_name: '', diff --git a/frontend/src/interfaces/index.ts b/frontend/src/interfaces/index.ts index 9cd159ff4da87bee6e6eaa6a7544c8ad98e04bb5..ff8f15f2fd98049e1e14675df685966e4147f3d2 100644 --- a/frontend/src/interfaces/index.ts +++ b/frontend/src/interfaces/index.ts @@ -64,6 +64,7 @@ export type FetchedRole = { export interface User { auth: boolean + auth_type: string fetched: boolean person_id: string sponsor_id: string diff --git a/frontend/src/providers/userProvider.tsx b/frontend/src/providers/userProvider.tsx index 2d1d17a18fa6ccfb7f0841b0ef3699fef588f64c..3a17e9d8e231791ab137fa8685929ed0e55c9565 100644 --- a/frontend/src/providers/userProvider.tsx +++ b/frontend/src/providers/userProvider.tsx @@ -10,6 +10,7 @@ function UserProvider(props: UserProviderProps) { const { children } = props const [user, setUser] = useState({ auth: false, + auth_type: '', fetched: false, first_name: '', last_name: '', @@ -31,6 +32,7 @@ function UserProvider(props: UserProviderProps) { if (response.ok) { setUser({ auth: true, + auth_type: data.auth_type, fetched: true, first_name: data.first_name, last_name: data.last_name, @@ -46,6 +48,7 @@ function UserProvider(props: UserProviderProps) { } else { setUser({ auth: false, + auth_type: '', fetched: true, first_name: '', last_name: '', @@ -62,6 +65,7 @@ function UserProvider(props: UserProviderProps) { } catch (error) { setUser({ auth: false, + auth_type: '', fetched: true, first_name: '', last_name: '', @@ -92,6 +96,7 @@ function UserProvider(props: UserProviderProps) { const clearUserInfo = () => { setUser({ auth: false, + auth_type: '', fetched: false, first_name: '', last_name: '', diff --git a/gregui/api/views/userinfo.py b/gregui/api/views/userinfo.py index b2e17997d1c50815c546f824839438480e9f9425..bba967c519e0c611d7018bd651a47c35bd984d96 100644 --- a/gregui/api/views/userinfo.py +++ b/gregui/api/views/userinfo.py @@ -34,6 +34,10 @@ class UserInfoView(APIView): user = request.user invite_id = request.session.get("invite_id") + auth_type = "invite" + if "oidc_states" in request.session.keys(): + auth_type = "oidc" + person = None sponsor = None content = { @@ -41,6 +45,7 @@ class UserInfoView(APIView): "sponsor_id": None, "person_id": None, "roles": [], + "auth_type": auth_type, } # Fetch sponsor and/or person object from profile of authenticated user