Skip to content
Snippets Groups Projects
Commit 93411b8c authored by Sivert Kronen Hatteberg's avatar Sivert Kronen Hatteberg
Browse files

Add a session type info to the user info endpoint

parent a5fe0678
No related branches found
No related tags found
1 merge request!192Greg 87 invitation logout
......@@ -12,6 +12,7 @@ function noop() {}
export const UserContext = createContext<IUserContext>({
user: {
auth: false,
auth_type: '',
fetched: false,
first_name: '',
last_name: '',
......
......@@ -64,6 +64,7 @@ export type FetchedRole = {
export interface User {
auth: boolean
auth_type: string
fetched: boolean
person_id: string
sponsor_id: string
......
......@@ -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: '',
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment