rlz-engine 1.0.20 → 1.0.21
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/client/state/auth.d.ts +1 -1
- package/dist/client/state/auth.js +12 -12
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ interface AuthState {
|
|
|
4
4
|
name: string | null;
|
|
5
5
|
email: string | null;
|
|
6
6
|
tempPassword: string | null;
|
|
7
|
+
authParam: () => AuthParam | null;
|
|
7
8
|
login: (id: string, name: string, email: string, tempPassword: string) => void;
|
|
8
9
|
logout: () => void;
|
|
9
10
|
}
|
|
@@ -18,5 +19,4 @@ export declare const useAuthState: import("zustand").UseBoundStore<Omit<import("
|
|
|
18
19
|
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AuthState, AuthState>>;
|
|
19
20
|
};
|
|
20
21
|
}>;
|
|
21
|
-
export declare function useAuthParam(): AuthParam | null;
|
|
22
22
|
export {};
|
|
@@ -9,22 +9,22 @@ localStorage.removeItem(AUTH_NAME_KEY);
|
|
|
9
9
|
localStorage.removeItem(AUTH_EMAIL_KEY);
|
|
10
10
|
localStorage.removeItem(AUTH_TEMP_PASSWORD_KEY);
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12
|
-
export const useAuthState = create()(persist(set => ({
|
|
12
|
+
export const useAuthState = create()(persist((set, get) => ({
|
|
13
13
|
id: null,
|
|
14
14
|
name: null,
|
|
15
15
|
email: null,
|
|
16
16
|
tempPassword: null,
|
|
17
|
+
authParam: () => {
|
|
18
|
+
const id = get().id;
|
|
19
|
+
const tempPassword = get().tempPassword;
|
|
20
|
+
if (id === null || tempPassword === null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
userId: id,
|
|
25
|
+
tempPassword
|
|
26
|
+
};
|
|
27
|
+
},
|
|
17
28
|
login: (id, name, email, tempPassword) => set({ id, name, email, tempPassword }),
|
|
18
29
|
logout: () => set({ id: null, name: null, email: null, tempPassword: null })
|
|
19
30
|
}), { name: 'AUTH' }));
|
|
20
|
-
export function useAuthParam() {
|
|
21
|
-
const id = useAuthState(i => i.id);
|
|
22
|
-
const tempPassword = useAuthState(i => i.tempPassword);
|
|
23
|
-
if (id === null || tempPassword === null) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
userId: id,
|
|
28
|
-
tempPassword
|
|
29
|
-
};
|
|
30
|
-
}
|