authera 1.2.8-test-11 → 1.2.8-test-12
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/hooks/useAuth.js +45 -48
- package/package.json +1 -1
package/dist/hooks/useAuth.js
CHANGED
|
@@ -6,55 +6,52 @@ export function useAuth() {
|
|
|
6
6
|
if (!ctx)
|
|
7
7
|
throw new Error("useAuth must be used within an AuthContext");
|
|
8
8
|
// -------------------------------------------------- data
|
|
9
|
-
const { permits: permitsData, ...user } = ctx.userData;
|
|
10
|
-
const authera_props = ctx.authera_props;
|
|
11
|
-
const prm = (permitsData || []);
|
|
9
|
+
// const { permits: permitsData, ...user } = ctx.userData;
|
|
10
|
+
// const authera_props = ctx.authera_props;
|
|
11
|
+
// const prm = (permitsData || []) as T[];
|
|
12
12
|
// -------------------------------------------------- funtions
|
|
13
|
-
const isPermitted = (perm) => {
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
const isPermittedAll = (perms) => {
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
const on = (perm, callback, fallback) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
ctx.set("refresh_token", null);
|
|
56
|
-
ctx.set("access_token", null);
|
|
57
|
-
};
|
|
13
|
+
// const isPermitted = (perm: T) => {
|
|
14
|
+
// return prm.includes(perm);
|
|
15
|
+
// };
|
|
16
|
+
// const isPermittedAll = (perms: T[]) => {
|
|
17
|
+
// return perms.every((p) => prm.includes(p));
|
|
18
|
+
// };
|
|
19
|
+
// const on = (perm: T, callback: () => void, fallback?: () => void) => {
|
|
20
|
+
// if (isPermitted(perm)) callback();
|
|
21
|
+
// else if (fallback) fallback();
|
|
22
|
+
// };
|
|
23
|
+
// const setUserData = (userData: userBaseData<T>) => {
|
|
24
|
+
// console.log("userData", userData);
|
|
25
|
+
// ctx.set("userData", userData);
|
|
26
|
+
// };
|
|
27
|
+
// const setPermits = (permits: T[]) => {
|
|
28
|
+
// ctx.set("userData", { ...ctx.userData, permits });
|
|
29
|
+
// };
|
|
30
|
+
// const addPermits = (permits: T[]) => {
|
|
31
|
+
// if (typeof permits !== "object") return;
|
|
32
|
+
// ctx.set("userData", {
|
|
33
|
+
// ...ctx.userData,
|
|
34
|
+
// permits: [...prm.filter((p) => !permits.includes(p)), ...permits],
|
|
35
|
+
// });
|
|
36
|
+
// };
|
|
37
|
+
// const removePermits = (permits: T[]) => {
|
|
38
|
+
// ctx.set("userData", {
|
|
39
|
+
// ...ctx.userData,
|
|
40
|
+
// permits: prm.filter((p) => !permits.includes(p)),
|
|
41
|
+
// });
|
|
42
|
+
// };
|
|
43
|
+
// const setAccessToken = (token: string) => {
|
|
44
|
+
// ctx.set("access_token", token);
|
|
45
|
+
// };
|
|
46
|
+
// const setRefreshToken = (token: string) => {
|
|
47
|
+
// ctx.set("refresh_token", token);
|
|
48
|
+
// };
|
|
49
|
+
// const logout = () => {
|
|
50
|
+
// setUserData(null as any);
|
|
51
|
+
// setPermits([]);
|
|
52
|
+
// ctx.set("refresh_token", null);
|
|
53
|
+
// ctx.set("access_token", null);
|
|
54
|
+
// };
|
|
58
55
|
return {
|
|
59
56
|
// permits: prm,
|
|
60
57
|
// isPermitted,
|