@data-fair/lib-vue 1.20.1 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/session.d.ts +2 -2
- package/session.js +10 -6
package/package.json
CHANGED
package/session.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface Session {
|
|
|
76
76
|
loginUrl: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => string;
|
|
77
77
|
login: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => void;
|
|
78
78
|
logout: (redirect?: string) => Promise<void>;
|
|
79
|
-
switchOrganization: (org: string | null, dep?: string, updateState?: boolean) => void;
|
|
79
|
+
switchOrganization: (org: string | null, dep?: string, role?: string, updateState?: boolean) => void;
|
|
80
80
|
setAdminMode: (adminMode: boolean, redirect?: string) => Promise<void>;
|
|
81
81
|
asAdmin: (user: any | null) => Promise<void>;
|
|
82
82
|
cancelDeletion: () => Promise<void>;
|
|
@@ -110,7 +110,7 @@ export declare function createSession(initOptions: Partial<SessionOptions>): Pro
|
|
|
110
110
|
loginUrl: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => string;
|
|
111
111
|
login: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => void;
|
|
112
112
|
logout: (redirect?: string) => Promise<void>;
|
|
113
|
-
switchOrganization: (org: string | null, dep?: string, updateState?: boolean) => void;
|
|
113
|
+
switchOrganization: (org: string | null, dep?: string, role?: string, updateState?: boolean) => void;
|
|
114
114
|
setAdminMode: (adminMode: boolean, redirect?: string) => Promise<void>;
|
|
115
115
|
asAdmin: (user: any | null) => Promise<void>;
|
|
116
116
|
cancelDeletion: () => Promise<void>;
|
package/session.js
CHANGED
|
@@ -95,12 +95,14 @@ export async function getSession (initOptions) {
|
|
|
95
95
|
state.user = user
|
|
96
96
|
const organizationId = cookies.get('id_token_org')
|
|
97
97
|
const departmentId = cookies.get('id_token_dep')
|
|
98
|
+
const switchedRole = cookies.get('id_token_role')
|
|
98
99
|
if (organizationId) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
state.organization = state.user.organizations.find(o => {
|
|
101
|
+
if (o.id !== organizationId) { return false }
|
|
102
|
+
if (departmentId && departmentId !== o.department) { return false }
|
|
103
|
+
if (switchedRole && switchedRole !== o.role) { return false }
|
|
104
|
+
return true
|
|
105
|
+
})
|
|
104
106
|
} else {
|
|
105
107
|
delete state.organization
|
|
106
108
|
}
|
|
@@ -185,12 +187,14 @@ export async function getSession (initOptions) {
|
|
|
185
187
|
cookies.remove('id_token')
|
|
186
188
|
cookies.remove('id_token_org')
|
|
187
189
|
cookies.remove('id_token_dep')
|
|
190
|
+
cookies.remove('id_token_role')
|
|
188
191
|
goTo(redirect ?? options.logoutRedirectUrl ?? null)
|
|
189
192
|
}
|
|
190
|
-
const switchOrganization = (org, dep, updateState = true) => {
|
|
193
|
+
const switchOrganization = (org, dep, role, updateState = true) => {
|
|
191
194
|
const cookieOpts = { path: cookiesPath }
|
|
192
195
|
if (org) { cookies.set('id_token_org', org, cookieOpts) } else { cookies.remove('id_token_org', cookieOpts) }
|
|
193
196
|
if (dep) { cookies.set('id_token_dep', dep, cookieOpts) } else { cookies.remove('id_token_dep', cookieOpts) }
|
|
197
|
+
if (role) { cookies.set('id_token_role', dep, cookieOpts) } else { cookies.remove('id_token_role', cookieOpts) }
|
|
194
198
|
if (updateState) { readState() }
|
|
195
199
|
}
|
|
196
200
|
const setAdminMode = async (adminMode, redirect) => {
|