rlz-engine 1.0.22 → 1.0.24

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.
@@ -4,7 +4,7 @@ export interface AuthState {
4
4
  name: string | null;
5
5
  email: string | null;
6
6
  tempPassword: string | null;
7
- authParam: () => AuthParam | null;
7
+ getAuthParam: () => AuthParam | null;
8
8
  login: (id: string, name: string, email: string, tempPassword: string) => void;
9
9
  logout: () => void;
10
10
  }
@@ -8,22 +8,27 @@ localStorage.removeItem(AUTH_ID_KEY);
8
8
  localStorage.removeItem(AUTH_NAME_KEY);
9
9
  localStorage.removeItem(AUTH_EMAIL_KEY);
10
10
  localStorage.removeItem(AUTH_TEMP_PASSWORD_KEY);
11
+ let cachedAuthParam = null;
11
12
  // eslint-disable-next-line @typescript-eslint/naming-convention
12
13
  export const useAuthState = create()(persist((set, get) => ({
13
14
  id: null,
14
15
  name: null,
15
16
  email: null,
16
17
  tempPassword: null,
17
- authParam: () => {
18
- const id = get().id;
19
- const tempPassword = get().tempPassword;
18
+ getAuthParam: () => {
19
+ const { id, tempPassword } = get();
20
20
  if (id === null || tempPassword === null) {
21
21
  return null;
22
22
  }
23
- return {
23
+ if (id === cachedAuthParam?.userId
24
+ && tempPassword === cachedAuthParam?.tempPassword) {
25
+ return cachedAuthParam;
26
+ }
27
+ cachedAuthParam = {
24
28
  userId: id,
25
29
  tempPassword
26
30
  };
31
+ return cachedAuthParam;
27
32
  },
28
33
  login: (id, name, email, tempPassword) => set({ id, name, email, tempPassword }),
29
34
  logout: () => set({ id: null, name: null, email: null, tempPassword: null })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlz-engine",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Deps and tools for my style of development",
5
5
  "scripts": {
6
6
  "build": "tsc",