rlz-engine 1.0.20 → 1.0.22
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.
|
@@ -23,6 +23,7 @@ export function SignupSigninScreen({ appName }) {
|
|
|
23
23
|
}
|
|
24
24
|
function SignupForm() {
|
|
25
25
|
const navigate = useNavigate();
|
|
26
|
+
const login = useAuthState(i => i.login);
|
|
26
27
|
const [syncInProgress, setSyncInProgress] = useState(false);
|
|
27
28
|
const [name, setName] = useState('');
|
|
28
29
|
const [nameActivated, setNameActivated] = useState(false);
|
|
@@ -36,7 +37,7 @@ function SignupForm() {
|
|
|
36
37
|
setSyncInProgress(true);
|
|
37
38
|
setTimeout(async () => {
|
|
38
39
|
try {
|
|
39
|
-
await signup(name, email, password, password2);
|
|
40
|
+
await signup(login, name, email, password, password2);
|
|
40
41
|
void navigate('/');
|
|
41
42
|
}
|
|
42
43
|
finally {
|
|
@@ -70,8 +71,7 @@ function SignupForm() {
|
|
|
70
71
|
marginLeft: '-12px'
|
|
71
72
|
} })))));
|
|
72
73
|
}
|
|
73
|
-
async function signup(name, email, password, password2) {
|
|
74
|
-
const login = useAuthState(i => i.login);
|
|
74
|
+
async function signup(login, name, email, password, password2) {
|
|
75
75
|
if (name === ''
|
|
76
76
|
|| !isValidEmail(email)
|
|
77
77
|
|| password === ''
|
|
@@ -82,6 +82,7 @@ async function signup(name, email, password, password2) {
|
|
|
82
82
|
login(resp.id, resp.name, resp.email, resp.tempPassword);
|
|
83
83
|
}
|
|
84
84
|
function SigninForm() {
|
|
85
|
+
const login = useAuthState(i => i.login);
|
|
85
86
|
const [syncInProgress, setSyncInProgress] = useState(false);
|
|
86
87
|
const navigate = useNavigate();
|
|
87
88
|
const [name, setName] = useState('');
|
|
@@ -90,7 +91,7 @@ function SigninForm() {
|
|
|
90
91
|
setSyncInProgress(true);
|
|
91
92
|
setTimeout(async () => {
|
|
92
93
|
try {
|
|
93
|
-
await signin(name, password);
|
|
94
|
+
await signin(login, name, password);
|
|
94
95
|
void navigate('/');
|
|
95
96
|
}
|
|
96
97
|
finally {
|
|
@@ -117,8 +118,7 @@ function SigninForm() {
|
|
|
117
118
|
marginLeft: '-12px'
|
|
118
119
|
} })))));
|
|
119
120
|
}
|
|
120
|
-
async function signin(name, password) {
|
|
121
|
-
const login = useAuthState(i => i.login);
|
|
121
|
+
async function signin(login, name, password) {
|
|
122
122
|
const resp = await apiSignin(name, password);
|
|
123
123
|
login(resp.id, resp.name, resp.email, resp.tempPassword);
|
|
124
124
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AuthParam } from '../api/api';
|
|
2
|
-
interface AuthState {
|
|
2
|
+
export interface AuthState {
|
|
3
3
|
id: string | null;
|
|
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,3 @@ 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
|
-
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
|
-
}
|