@vocollege/app 0.0.75 → 0.0.77
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/dist/global.d.ts +0 -3
- package/dist/interceptor.js +6 -4
- package/dist/modules/VoApi/GraphClient.js +2 -1
- package/dist/modules/VoApi/queries/users.d.ts +1 -0
- package/dist/modules/VoApi/queries/users.js +4 -3
- package/dist/modules/VoAuth.js +70 -43
- package/dist/modules/VoConfig.js +6 -6
- package/package.json +1 -1
- package/src/global.ts +3 -3
- package/src/interceptor.ts +6 -4
- package/src/modules/VoApi/GraphClient.ts +2 -1
- package/src/modules/VoApi/queries/users.ts +28 -0
- package/src/modules/VoAuth.ts +76 -43
- package/src/modules/VoConfig.ts +6 -6
package/dist/global.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare type AuthStorageConfigType = {
|
|
|
4
4
|
REFRESH_TOKEN: string;
|
|
5
5
|
ACCESS_TOKEN: string;
|
|
6
6
|
TOKEN_TYPE: string;
|
|
7
|
-
EXPIRES_IN: string;
|
|
8
7
|
};
|
|
9
8
|
export declare type AuthConfigType = {
|
|
10
9
|
BASE_URL: string;
|
|
@@ -31,10 +30,8 @@ export declare type VoAppType = {
|
|
|
31
30
|
api: any;
|
|
32
31
|
};
|
|
33
32
|
export declare type VoTokenType = {
|
|
34
|
-
token_type: string;
|
|
35
33
|
access_token: string;
|
|
36
34
|
refresh_token: string;
|
|
37
|
-
expires_in: string;
|
|
38
35
|
};
|
|
39
36
|
export interface GeneralObject {
|
|
40
37
|
[key: string]: any;
|
package/dist/interceptor.js
CHANGED
|
@@ -103,7 +103,8 @@ var I18n_1 = __importDefault(require("./modules/Services/I18n"));
|
|
|
103
103
|
if (token) {
|
|
104
104
|
retry = 0;
|
|
105
105
|
error.config.headers["Authorization"] =
|
|
106
|
-
token.token_type + " " + token.access_token;
|
|
106
|
+
// token.token_type + " " + token.access_token;
|
|
107
|
+
"Bearer " + token.access_token;
|
|
107
108
|
}
|
|
108
109
|
return [2 /*return*/, axios_1.default.request(error.config)];
|
|
109
110
|
case 3:
|
|
@@ -116,9 +117,10 @@ var I18n_1 = __importDefault(require("./modules/Services/I18n"));
|
|
|
116
117
|
switch (status) {
|
|
117
118
|
case 419:
|
|
118
119
|
react_toastify_1.toast.error(I18n_1.default.get.messages.sessionExpired);
|
|
119
|
-
setTimeout(
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
// setTimeout(() => {
|
|
121
|
+
redirect();
|
|
122
|
+
reject(error);
|
|
123
|
+
// }, 5000);
|
|
122
124
|
break;
|
|
123
125
|
default:
|
|
124
126
|
reject(error);
|
|
@@ -175,7 +175,8 @@ var GraphClient = /** @class */ (function () {
|
|
|
175
175
|
}
|
|
176
176
|
operation.setContext(function () { return (__assign(__assign({}, currentHeaders), { headers: {
|
|
177
177
|
Authorization: token
|
|
178
|
-
?
|
|
178
|
+
? // ? `${token.token_type} ${token.access_token}`
|
|
179
|
+
"Bearer ".concat(token.access_token)
|
|
179
180
|
: "",
|
|
180
181
|
VoGroup: groupId,
|
|
181
182
|
} })); });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const GET_USERS_FIELDS: import("@apollo/client").DocumentNode;
|
|
2
2
|
export declare const GET_USER: import("@apollo/client").DocumentNode;
|
|
3
3
|
export declare const GET_USERS: import("@apollo/client").DocumentNode;
|
|
4
|
+
export declare const GET_USERS_SIMPLIFIED: import("@apollo/client").DocumentNode;
|
|
4
5
|
export declare const GET_ACCOUNT: import("@apollo/client").DocumentNode;
|
|
@@ -4,10 +4,11 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.GET_ACCOUNT = exports.GET_USERS = exports.GET_USER = exports.GET_USERS_FIELDS = void 0;
|
|
7
|
+
exports.GET_ACCOUNT = exports.GET_USERS_SIMPLIFIED = exports.GET_USERS = exports.GET_USER = exports.GET_USERS_FIELDS = void 0;
|
|
8
8
|
var client_1 = require("@apollo/client");
|
|
9
9
|
exports.GET_USERS_FIELDS = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n fragment UsersFields on User {\n id\n name\n email\n active\n status\n updated_at\n created_at\n roles {\n id\n label\n type\n }\n groupRoles {\n id\n label\n type\n }\n groups {\n id\n name\n title\n }\n validig {\n id\n }\n }\n"], ["\n fragment UsersFields on User {\n id\n name\n email\n active\n status\n updated_at\n created_at\n roles {\n id\n label\n type\n }\n groupRoles {\n id\n label\n type\n }\n groups {\n id\n name\n title\n }\n validig {\n id\n }\n }\n"])));
|
|
10
10
|
exports.GET_USER = (0, client_1.gql)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query User($id: ID!) {\n user(id: $id) {\n id\n name\n email\n firstname\n lastname\n active\n personal_number\n address1\n address2\n postalcode\n town\n country\n phone1\n profession\n status\n gdpr\n description\n updated_at\n created_at\n images {\n id\n title\n filename\n filesize\n filetype\n url\n }\n roles {\n id\n label\n type\n }\n groupRoles {\n id\n label\n type\n }\n groups {\n id\n title\n type\n }\n }\n }\n"], ["\n query User($id: ID!) {\n user(id: $id) {\n id\n name\n email\n firstname\n lastname\n active\n personal_number\n address1\n address2\n postalcode\n town\n country\n phone1\n profession\n status\n gdpr\n description\n updated_at\n created_at\n images {\n id\n title\n filename\n filesize\n filetype\n url\n }\n roles {\n id\n label\n type\n }\n groupRoles {\n id\n label\n type\n }\n groups {\n id\n title\n type\n }\n }\n }\n"])));
|
|
11
11
|
exports.GET_USERS = (0, client_1.gql)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n # query Users($page: Int!, $search: String) {\n # users(page: $page, search: $search) {\n # paginatorInfo {\n # total\n # currentPage\n # hasMorePages\n # }\n # data {\n # name\n # email\n # }\n # }\n # }\n\n query Users(\n $search: String\n $page: Int\n $limit: Int\n $orderBy: [GetUsersOrderByClause]\n $filters: [GetUsersFilter]\n ) {\n allGroups(categories: [\"region\", \"local\"]) {\n id\n title\n }\n roles {\n id\n name\n label\n }\n users(\n search: $search\n page: $page\n limit: $limit\n orderBy: $orderBy\n filters: $filters\n ) {\n paginatorInfo {\n total\n currentPage\n hasMorePages\n }\n data {\n ...UsersFields\n }\n }\n }\n ", "\n"], ["\n # query Users($page: Int!, $search: String) {\n # users(page: $page, search: $search) {\n # paginatorInfo {\n # total\n # currentPage\n # hasMorePages\n # }\n # data {\n # name\n # email\n # }\n # }\n # }\n\n query Users(\n $search: String\n $page: Int\n $limit: Int\n $orderBy: [GetUsersOrderByClause]\n $filters: [GetUsersFilter]\n ) {\n allGroups(categories: [\"region\", \"local\"]) {\n id\n title\n }\n roles {\n id\n name\n label\n }\n users(\n search: $search\n page: $page\n limit: $limit\n orderBy: $orderBy\n filters: $filters\n ) {\n paginatorInfo {\n total\n currentPage\n hasMorePages\n }\n data {\n ...UsersFields\n }\n }\n }\n ", "\n"])), exports.GET_USERS_FIELDS);
|
|
12
|
-
exports.
|
|
13
|
-
|
|
12
|
+
exports.GET_USERS_SIMPLIFIED = (0, client_1.gql)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n query UsersSimplified(\n $search: String\n $page: Int\n $limit: Int\n $orderBy: [GetUsersOrderByClause]\n $filters: [GetUsersFilter]\n ) {\n users(\n search: $search\n page: $page\n limit: $limit\n orderBy: $orderBy\n filters: $filters\n ) {\n paginatorInfo {\n total\n currentPage\n hasMorePages\n }\n data {\n ...UsersFields\n }\n }\n }\n ", "\n"], ["\n query UsersSimplified(\n $search: String\n $page: Int\n $limit: Int\n $orderBy: [GetUsersOrderByClause]\n $filters: [GetUsersFilter]\n ) {\n users(\n search: $search\n page: $page\n limit: $limit\n orderBy: $orderBy\n filters: $filters\n ) {\n paginatorInfo {\n total\n currentPage\n hasMorePages\n }\n data {\n ...UsersFields\n }\n }\n }\n ", "\n"])), exports.GET_USERS_FIELDS);
|
|
13
|
+
exports.GET_ACCOUNT = (0, client_1.gql)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n query Account($id: ID!) {\n user(id: $id) {\n id\n name\n email\n firstname\n lastname\n active\n personal_number\n address1\n address2\n postalcode\n town\n country\n phone1\n profession\n status\n description\n workplace\n gdpr\n images {\n id\n title\n filename\n filesize\n filetype\n url\n }\n }\n userSettings {\n publicDefaultPortfolio {\n id\n name\n disk\n }\n }\n }\n"], ["\n query Account($id: ID!) {\n user(id: $id) {\n id\n name\n email\n firstname\n lastname\n active\n personal_number\n address1\n address2\n postalcode\n town\n country\n phone1\n profession\n status\n description\n workplace\n gdpr\n images {\n id\n title\n filename\n filesize\n filetype\n url\n }\n }\n userSettings {\n publicDefaultPortfolio {\n id\n name\n disk\n }\n }\n }\n"])));
|
|
14
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
package/dist/modules/VoAuth.js
CHANGED
|
@@ -197,37 +197,39 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
197
197
|
}); });
|
|
198
198
|
};
|
|
199
199
|
VoAuth.prototype.setSession = function (token) {
|
|
200
|
-
|
|
200
|
+
// const { token_type, access_token, refresh_token, expires_in } = token;
|
|
201
|
+
var access_token = token.access_token, refresh_token = token.refresh_token;
|
|
201
202
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
202
203
|
// Helpers.localStorage.set(refreshTokenKey, refresh_token);
|
|
203
204
|
js_cookie_1.default.set(refreshTokenKey, refresh_token, {
|
|
204
|
-
expires:
|
|
205
|
+
expires: 11,
|
|
205
206
|
sameSite: "Lax",
|
|
206
207
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
207
208
|
});
|
|
208
209
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
209
210
|
// Helpers.localStorage.set(accessTokenKey, access_token);
|
|
210
211
|
js_cookie_1.default.set(accessTokenKey, access_token, {
|
|
211
|
-
expires:
|
|
212
|
-
sameSite: "Lax",
|
|
213
|
-
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
214
|
-
});
|
|
215
|
-
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
216
|
-
// Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
217
|
-
js_cookie_1.default.set(tokenTypeKey, token_type, {
|
|
218
|
-
expires: 20,
|
|
219
|
-
sameSite: "Lax",
|
|
220
|
-
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
221
|
-
});
|
|
222
|
-
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
223
|
-
// Helpers.localStorage.set(expiresInKey, expires_in);
|
|
224
|
-
js_cookie_1.default.set(expiresInKey, expires_in, {
|
|
225
|
-
expires: 20,
|
|
212
|
+
expires: 1,
|
|
226
213
|
sameSite: "Lax",
|
|
227
214
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
228
215
|
});
|
|
216
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
217
|
+
// // Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
218
|
+
// JsCookies.set(tokenTypeKey, token_type, {
|
|
219
|
+
// expires: 11,
|
|
220
|
+
// sameSite: "Lax",
|
|
221
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
222
|
+
// });
|
|
223
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
224
|
+
// // Helpers.localStorage.set(expiresInKey, expires_in);
|
|
225
|
+
// JsCookies.set(expiresInKey, expires_in, {
|
|
226
|
+
// expires: 11,
|
|
227
|
+
// sameSite: "Lax",
|
|
228
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
229
|
+
// });
|
|
229
230
|
axios_1.default.defaults.headers.common["Authorization"] =
|
|
230
|
-
token_type + " " + access_token;
|
|
231
|
+
// token_type + " " + access_token;
|
|
232
|
+
"Bearer " + access_token;
|
|
231
233
|
var currentGroup = VoGroups_1.default.getCurrent(true);
|
|
232
234
|
axios_1.default.defaults.headers.common["VoGroup"] = currentGroup
|
|
233
235
|
? currentGroup.id
|
|
@@ -246,18 +248,18 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
246
248
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
247
249
|
sameSite: "Lax",
|
|
248
250
|
});
|
|
249
|
-
|
|
250
|
-
Helpers.localStorage.remove(tokenTypeKey);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
Helpers.localStorage.remove(expiresInKey);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
251
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
252
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
253
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
254
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
255
|
+
// sameSite: "Lax",
|
|
256
|
+
// });
|
|
257
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
258
|
+
// Helpers.localStorage.remove(expiresInKey);
|
|
259
|
+
// JsCookies.remove(expiresInKey, {
|
|
260
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
261
|
+
// sameSite: "Lax",
|
|
262
|
+
// });
|
|
261
263
|
Helpers.localStorage.remove(VoConfig_1.default.get.CURRENT_GROUP || "");
|
|
262
264
|
Helpers.localStorage.remove(VoConfig_1.default.get.MASQUERADE_USER || "");
|
|
263
265
|
delete axios_1.default.defaults.headers.common["Authorization"];
|
|
@@ -303,10 +305,25 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
303
305
|
if (forceLoad === void 0) { forceLoad = false; }
|
|
304
306
|
this.checkConfig();
|
|
305
307
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
306
|
-
var token, error_3;
|
|
308
|
+
var currentCookies, cookieName, token, error_3;
|
|
307
309
|
return __generator(this, function (_a) {
|
|
308
310
|
switch (_a.label) {
|
|
309
311
|
case 0:
|
|
312
|
+
currentCookies = js_cookie_1.default.get();
|
|
313
|
+
for (cookieName in currentCookies) {
|
|
314
|
+
console.log("cookieName", cookieName);
|
|
315
|
+
if ([
|
|
316
|
+
"XSRF-TOKEN",
|
|
317
|
+
"voapp_redirectTo",
|
|
318
|
+
"vo_organisation",
|
|
319
|
+
VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN,
|
|
320
|
+
VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN,
|
|
321
|
+
].indexOf(cookieName) === -1) {
|
|
322
|
+
js_cookie_1.default.remove(cookieName, {
|
|
323
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
310
327
|
token = this.getToken();
|
|
311
328
|
if (!token) return [3 /*break*/, 5];
|
|
312
329
|
_a.label = 1;
|
|
@@ -382,18 +399,19 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
382
399
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
383
400
|
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
384
401
|
var accessToken = js_cookie_1.default.get(accessTokenKey);
|
|
385
|
-
|
|
386
|
-
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
390
|
-
|
|
391
|
-
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
402
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
403
|
+
// // const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
404
|
+
// const tokenType = JsCookies.get(tokenTypeKey);
|
|
405
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
406
|
+
// // const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
407
|
+
// const expiresIn = JsCookies.get(expiresInKey);
|
|
408
|
+
// if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
409
|
+
if (refreshToken && accessToken) {
|
|
392
410
|
return {
|
|
393
411
|
refresh_token: refreshToken,
|
|
394
412
|
access_token: accessToken,
|
|
395
|
-
token_type: tokenType,
|
|
396
|
-
expires_in: expiresIn,
|
|
413
|
+
// token_type: tokenType,
|
|
414
|
+
// expires_in: expiresIn,
|
|
397
415
|
};
|
|
398
416
|
}
|
|
399
417
|
}
|
|
@@ -428,13 +446,22 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
428
446
|
js_cookie_1.default.remove(accessTokenKey, {
|
|
429
447
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
430
448
|
sameSite: "Lax",
|
|
449
|
+
expires: 1,
|
|
431
450
|
});
|
|
432
|
-
var
|
|
433
|
-
Helpers.localStorage.remove(
|
|
434
|
-
js_cookie_1.default.remove(
|
|
451
|
+
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
452
|
+
Helpers.localStorage.remove(refreshTokenKey);
|
|
453
|
+
js_cookie_1.default.remove(refreshTokenKey, {
|
|
435
454
|
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
436
455
|
sameSite: "Lax",
|
|
456
|
+
expires: 1,
|
|
437
457
|
});
|
|
458
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
459
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
460
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
461
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
462
|
+
// sameSite: "Lax",
|
|
463
|
+
// expires: 12,
|
|
464
|
+
// });
|
|
438
465
|
return {
|
|
439
466
|
state: state,
|
|
440
467
|
challenge: challenge,
|
package/dist/modules/VoConfig.js
CHANGED
|
@@ -43,12 +43,12 @@ var VoConfig = /** @class */ (function () {
|
|
|
43
43
|
LOGIN: "",
|
|
44
44
|
HOME: "",
|
|
45
45
|
HOME_AUTHENTICATED: "",
|
|
46
|
-
AUTH_STORAGE_STATE: "
|
|
47
|
-
AUTH_STORAGE_VERIFIER: "
|
|
48
|
-
AUTH_STORAGE_REFRESH_TOKEN: "
|
|
49
|
-
AUTH_STORAGE_ACCESS_TOKEN: "
|
|
50
|
-
AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
-
AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
46
|
+
AUTH_STORAGE_STATE: "vo_state",
|
|
47
|
+
AUTH_STORAGE_VERIFIER: "vo_verifier",
|
|
48
|
+
AUTH_STORAGE_REFRESH_TOKEN: "vo_rtoken",
|
|
49
|
+
AUTH_STORAGE_ACCESS_TOKEN: "vo_atoken",
|
|
50
|
+
// AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
+
// AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
52
52
|
AUTH_DOMAIN: ".vo-college.se",
|
|
53
53
|
CURRENT_GROUP: "vo_group",
|
|
54
54
|
MASQUERADE_USER: "vo_masquerade",
|
package/package.json
CHANGED
package/src/global.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type AuthStorageConfigType = {
|
|
|
4
4
|
REFRESH_TOKEN: string;
|
|
5
5
|
ACCESS_TOKEN: string;
|
|
6
6
|
TOKEN_TYPE: string;
|
|
7
|
-
EXPIRES_IN: string;
|
|
7
|
+
// EXPIRES_IN: string;
|
|
8
8
|
};
|
|
9
9
|
export type AuthConfigType = {
|
|
10
10
|
BASE_URL: string;
|
|
@@ -31,10 +31,10 @@ export type VoAppType = {
|
|
|
31
31
|
api: any;
|
|
32
32
|
};
|
|
33
33
|
export type VoTokenType = {
|
|
34
|
-
token_type: string;
|
|
34
|
+
// token_type: string;
|
|
35
35
|
access_token: string;
|
|
36
36
|
refresh_token: string;
|
|
37
|
-
expires_in: string;
|
|
37
|
+
// expires_in: string;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export interface GeneralObject {
|
package/src/interceptor.ts
CHANGED
|
@@ -48,7 +48,8 @@ import I18n from "./modules/Services/I18n";
|
|
|
48
48
|
if (token) {
|
|
49
49
|
retry = 0;
|
|
50
50
|
error.config.headers["Authorization"] =
|
|
51
|
-
token.token_type + " " + token.access_token;
|
|
51
|
+
// token.token_type + " " + token.access_token;
|
|
52
|
+
"Bearer " + token.access_token;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
return axios.request(error.config);
|
|
@@ -64,9 +65,10 @@ import I18n from "./modules/Services/I18n";
|
|
|
64
65
|
switch (status) {
|
|
65
66
|
case 419:
|
|
66
67
|
toast.error(I18n.get.messages.sessionExpired);
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
// setTimeout(() => {
|
|
69
|
+
redirect();
|
|
70
|
+
reject(error);
|
|
71
|
+
// }, 5000);
|
|
70
72
|
break;
|
|
71
73
|
default:
|
|
72
74
|
reject(error);
|
|
@@ -137,7 +137,8 @@ class GraphClient {
|
|
|
137
137
|
...currentHeaders,
|
|
138
138
|
headers: {
|
|
139
139
|
Authorization: token
|
|
140
|
-
? `${token.token_type} ${token.access_token}`
|
|
140
|
+
? // ? `${token.token_type} ${token.access_token}`
|
|
141
|
+
`Bearer ${token.access_token}`
|
|
141
142
|
: "",
|
|
142
143
|
VoGroup: groupId,
|
|
143
144
|
},
|
|
@@ -130,6 +130,34 @@ export const GET_USERS = gql`
|
|
|
130
130
|
${GET_USERS_FIELDS}
|
|
131
131
|
`;
|
|
132
132
|
|
|
133
|
+
export const GET_USERS_SIMPLIFIED = gql`
|
|
134
|
+
query UsersSimplified(
|
|
135
|
+
$search: String
|
|
136
|
+
$page: Int
|
|
137
|
+
$limit: Int
|
|
138
|
+
$orderBy: [GetUsersOrderByClause]
|
|
139
|
+
$filters: [GetUsersFilter]
|
|
140
|
+
) {
|
|
141
|
+
users(
|
|
142
|
+
search: $search
|
|
143
|
+
page: $page
|
|
144
|
+
limit: $limit
|
|
145
|
+
orderBy: $orderBy
|
|
146
|
+
filters: $filters
|
|
147
|
+
) {
|
|
148
|
+
paginatorInfo {
|
|
149
|
+
total
|
|
150
|
+
currentPage
|
|
151
|
+
hasMorePages
|
|
152
|
+
}
|
|
153
|
+
data {
|
|
154
|
+
...UsersFields
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
${GET_USERS_FIELDS}
|
|
159
|
+
`;
|
|
160
|
+
|
|
133
161
|
export const GET_ACCOUNT = gql`
|
|
134
162
|
query Account($id: ID!) {
|
|
135
163
|
user(id: $id) {
|
package/src/modules/VoAuth.ts
CHANGED
|
@@ -99,12 +99,13 @@ class VoAuth extends VoBase {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
setSession(token: any) {
|
|
102
|
-
const { token_type, access_token, refresh_token, expires_in } = token;
|
|
102
|
+
// const { token_type, access_token, refresh_token, expires_in } = token;
|
|
103
|
+
const { access_token, refresh_token } = token;
|
|
103
104
|
|
|
104
105
|
let refreshTokenKey = VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
105
106
|
// Helpers.localStorage.set(refreshTokenKey, refresh_token);
|
|
106
107
|
JsCookies.set(refreshTokenKey, refresh_token, {
|
|
107
|
-
expires:
|
|
108
|
+
expires: 11,
|
|
108
109
|
sameSite: "Lax",
|
|
109
110
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
110
111
|
});
|
|
@@ -112,29 +113,30 @@ class VoAuth extends VoBase {
|
|
|
112
113
|
let accessTokenKey = VoConfig.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
113
114
|
// Helpers.localStorage.set(accessTokenKey, access_token);
|
|
114
115
|
JsCookies.set(accessTokenKey, access_token, {
|
|
115
|
-
expires:
|
|
116
|
+
expires: 1,
|
|
116
117
|
sameSite: "Lax",
|
|
117
118
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
118
119
|
});
|
|
119
120
|
|
|
120
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
121
|
-
// Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
122
|
-
JsCookies.set(tokenTypeKey, token_type, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
129
|
-
// Helpers.localStorage.set(expiresInKey, expires_in);
|
|
130
|
-
JsCookies.set(expiresInKey, expires_in, {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
121
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
122
|
+
// // Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
123
|
+
// JsCookies.set(tokenTypeKey, token_type, {
|
|
124
|
+
// expires: 11,
|
|
125
|
+
// sameSite: "Lax",
|
|
126
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
127
|
+
// });
|
|
128
|
+
|
|
129
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
130
|
+
// // Helpers.localStorage.set(expiresInKey, expires_in);
|
|
131
|
+
// JsCookies.set(expiresInKey, expires_in, {
|
|
132
|
+
// expires: 11,
|
|
133
|
+
// sameSite: "Lax",
|
|
134
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
135
|
+
// });
|
|
135
136
|
|
|
136
137
|
axios.defaults.headers.common["Authorization"] =
|
|
137
|
-
token_type + " " + access_token;
|
|
138
|
+
// token_type + " " + access_token;
|
|
139
|
+
"Bearer " + access_token;
|
|
138
140
|
let currentGroup = VoGroups.getCurrent(true);
|
|
139
141
|
axios.defaults.headers.common["VoGroup"] = currentGroup
|
|
140
142
|
? currentGroup.id
|
|
@@ -155,19 +157,19 @@ class VoAuth extends VoBase {
|
|
|
155
157
|
sameSite: "Lax",
|
|
156
158
|
});
|
|
157
159
|
|
|
158
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
159
|
-
Helpers.localStorage.remove(tokenTypeKey);
|
|
160
|
-
JsCookies.remove(tokenTypeKey, {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
160
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
161
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
162
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
163
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
164
|
+
// sameSite: "Lax",
|
|
165
|
+
// });
|
|
164
166
|
|
|
165
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
166
|
-
Helpers.localStorage.remove(expiresInKey);
|
|
167
|
-
JsCookies.remove(expiresInKey, {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
167
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
168
|
+
// Helpers.localStorage.remove(expiresInKey);
|
|
169
|
+
// JsCookies.remove(expiresInKey, {
|
|
170
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
171
|
+
// sameSite: "Lax",
|
|
172
|
+
// });
|
|
171
173
|
|
|
172
174
|
Helpers.localStorage.remove(VoConfig.get.CURRENT_GROUP || "");
|
|
173
175
|
Helpers.localStorage.remove(VoConfig.get.MASQUERADE_USER || "");
|
|
@@ -199,9 +201,29 @@ class VoAuth extends VoBase {
|
|
|
199
201
|
throw error;
|
|
200
202
|
}
|
|
201
203
|
}
|
|
204
|
+
|
|
202
205
|
check(forceRedirect = false, forceLoad = false): Promise<any> {
|
|
203
206
|
this.checkConfig();
|
|
204
207
|
return new Promise(async (resolve, reject) => {
|
|
208
|
+
// VC-231 | Clear up unnecessary cookies.
|
|
209
|
+
let currentCookies = JsCookies.get();
|
|
210
|
+
for (const cookieName in currentCookies) {
|
|
211
|
+
console.log("cookieName", cookieName);
|
|
212
|
+
if (
|
|
213
|
+
[
|
|
214
|
+
"XSRF-TOKEN",
|
|
215
|
+
"voapp_redirectTo",
|
|
216
|
+
"vo_organisation",
|
|
217
|
+
VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN,
|
|
218
|
+
VoConfig.get.AUTH_STORAGE_ACCESS_TOKEN,
|
|
219
|
+
].indexOf(cookieName) === -1
|
|
220
|
+
) {
|
|
221
|
+
JsCookies.remove(cookieName, {
|
|
222
|
+
domain: VoConfig.get.AUTH_DOMAIN,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
205
227
|
const token = this.getToken();
|
|
206
228
|
if (token) {
|
|
207
229
|
try {
|
|
@@ -251,20 +273,21 @@ class VoAuth extends VoBase {
|
|
|
251
273
|
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
252
274
|
const accessToken = JsCookies.get(accessTokenKey);
|
|
253
275
|
|
|
254
|
-
let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
255
|
-
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
256
|
-
const tokenType = JsCookies.get(tokenTypeKey);
|
|
276
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
277
|
+
// // const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
278
|
+
// const tokenType = JsCookies.get(tokenTypeKey);
|
|
257
279
|
|
|
258
|
-
let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
259
|
-
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
260
|
-
const expiresIn = JsCookies.get(expiresInKey);
|
|
280
|
+
// let expiresInKey = VoConfig.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
281
|
+
// // const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
282
|
+
// const expiresIn = JsCookies.get(expiresInKey);
|
|
261
283
|
|
|
262
|
-
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
284
|
+
// if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
285
|
+
if (refreshToken && accessToken) {
|
|
263
286
|
return {
|
|
264
287
|
refresh_token: refreshToken,
|
|
265
288
|
access_token: accessToken,
|
|
266
|
-
token_type: tokenType,
|
|
267
|
-
expires_in: expiresIn,
|
|
289
|
+
// token_type: tokenType,
|
|
290
|
+
// expires_in: expiresIn,
|
|
268
291
|
};
|
|
269
292
|
}
|
|
270
293
|
} catch (error) {
|
|
@@ -303,15 +326,25 @@ class VoAuth extends VoBase {
|
|
|
303
326
|
JsCookies.remove(accessTokenKey, {
|
|
304
327
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
305
328
|
sameSite: "Lax",
|
|
329
|
+
expires: 1,
|
|
306
330
|
});
|
|
307
331
|
|
|
308
|
-
let
|
|
309
|
-
Helpers.localStorage.remove(
|
|
310
|
-
JsCookies.remove(
|
|
332
|
+
let refreshTokenKey = VoConfig.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
333
|
+
Helpers.localStorage.remove(refreshTokenKey);
|
|
334
|
+
JsCookies.remove(refreshTokenKey, {
|
|
311
335
|
domain: VoConfig.get.AUTH_DOMAIN,
|
|
312
336
|
sameSite: "Lax",
|
|
337
|
+
expires: 1,
|
|
313
338
|
});
|
|
314
339
|
|
|
340
|
+
// let tokenTypeKey = VoConfig.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
341
|
+
// Helpers.localStorage.remove(tokenTypeKey);
|
|
342
|
+
// JsCookies.remove(tokenTypeKey, {
|
|
343
|
+
// domain: VoConfig.get.AUTH_DOMAIN,
|
|
344
|
+
// sameSite: "Lax",
|
|
345
|
+
// expires: 12,
|
|
346
|
+
// });
|
|
347
|
+
|
|
315
348
|
return {
|
|
316
349
|
state,
|
|
317
350
|
challenge,
|
package/src/modules/VoConfig.ts
CHANGED
|
@@ -43,12 +43,12 @@ class VoConfig {
|
|
|
43
43
|
HOME: "",
|
|
44
44
|
HOME_AUTHENTICATED: "",
|
|
45
45
|
|
|
46
|
-
AUTH_STORAGE_STATE: "
|
|
47
|
-
AUTH_STORAGE_VERIFIER: "
|
|
48
|
-
AUTH_STORAGE_REFRESH_TOKEN: "
|
|
49
|
-
AUTH_STORAGE_ACCESS_TOKEN: "
|
|
50
|
-
AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
-
AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
46
|
+
AUTH_STORAGE_STATE: "vo_state",
|
|
47
|
+
AUTH_STORAGE_VERIFIER: "vo_verifier",
|
|
48
|
+
AUTH_STORAGE_REFRESH_TOKEN: "vo_rtoken",
|
|
49
|
+
AUTH_STORAGE_ACCESS_TOKEN: "vo_atoken",
|
|
50
|
+
// AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
51
|
+
// AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
52
52
|
AUTH_DOMAIN: ".vo-college.se",
|
|
53
53
|
|
|
54
54
|
CURRENT_GROUP: "vo_group",
|