@usequeek/theme-kit 0.3.0 → 0.3.2
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/apps/apps.css +4 -0
- package/hooks/use-auth-flow.tsx +32 -11
- package/package.json +1 -1
package/apps/apps.css
CHANGED
|
@@ -586,6 +586,10 @@
|
|
|
586
586
|
flex-direction: column;
|
|
587
587
|
align-items: stretch;
|
|
588
588
|
}
|
|
589
|
+
/* Stacked, `flex: 1 1 20rem` would set a 320px HEIGHT on the text: size it to its lines instead. */
|
|
590
|
+
.core-consent-banner__text {
|
|
591
|
+
flex: 0 1 auto;
|
|
592
|
+
}
|
|
589
593
|
.core-consent-banner__actions {
|
|
590
594
|
justify-content: flex-end;
|
|
591
595
|
}
|
package/hooks/use-auth-flow.tsx
CHANGED
|
@@ -97,6 +97,8 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
|
|
|
97
97
|
const [step, setStep] = useState<AuthStep>('email-otp');
|
|
98
98
|
const [otp, setOtp] = useState('');
|
|
99
99
|
const [verifiedToken, setVerifiedToken] = useState(''); // email OTP flow: server-issued token
|
|
100
|
+
// Password sign-up: the address is proven by the same email code first; the typed name/password wait here until it is.
|
|
101
|
+
const [passwordSignup, setPasswordSignup] = useState(false);
|
|
100
102
|
const [firstName, setFirstName] = useState('');
|
|
101
103
|
const [lastName, setLastName] = useState('');
|
|
102
104
|
const [email, setEmail] = useState('');
|
|
@@ -146,6 +148,23 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
|
|
|
146
148
|
}
|
|
147
149
|
};
|
|
148
150
|
|
|
151
|
+
// The proven address is the only way to name an email at register-password: the server refuses a password sign-up without it.
|
|
152
|
+
const registerWithPassword = async (client: ReturnType<typeof getQueekClient>, proof: string): Promise<void> => {
|
|
153
|
+
const res = await client.post<PasswordAuthData>('/client/auth/email/register-password', {
|
|
154
|
+
first_name: firstName.trim(),
|
|
155
|
+
last_name: lastName.trim() || undefined,
|
|
156
|
+
email: email.trim(),
|
|
157
|
+
password,
|
|
158
|
+
phone: '',
|
|
159
|
+
platform: 'client_web',
|
|
160
|
+
verified_token: proof,
|
|
161
|
+
});
|
|
162
|
+
setAuthTokens(res.data.access_token, res.data.refresh_token);
|
|
163
|
+
applyUser(res.data.user);
|
|
164
|
+
setPasswordSignup(false);
|
|
165
|
+
closeModal();
|
|
166
|
+
};
|
|
167
|
+
|
|
149
168
|
const submitEmailVerifyOtp = async (): Promise<void> => {
|
|
150
169
|
if (blockPreview()) return;
|
|
151
170
|
if (otp.length < EMAIL_OTP_LENGTH) return;
|
|
@@ -158,12 +177,17 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
|
|
|
158
177
|
otpCode: otp,
|
|
159
178
|
});
|
|
160
179
|
if (data.needs_registration) {
|
|
180
|
+
if (passwordSignup) {
|
|
181
|
+
await registerWithPassword(client, data.verified_token);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
161
184
|
setVerifiedToken(data.verified_token);
|
|
162
185
|
setStep('signup');
|
|
163
186
|
return;
|
|
164
187
|
}
|
|
165
188
|
// tokens already persisted by SDK
|
|
166
189
|
applyUser(data.user);
|
|
190
|
+
setPasswordSignup(false);
|
|
167
191
|
closeModal();
|
|
168
192
|
} catch (err) {
|
|
169
193
|
setError(mapEmailError(err, t));
|
|
@@ -231,17 +255,10 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
|
|
|
231
255
|
setLoading(true);
|
|
232
256
|
try {
|
|
233
257
|
const client = getQueekClient(vendor.slug ?? undefined);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
password,
|
|
239
|
-
phone: '',
|
|
240
|
-
platform: 'client_web',
|
|
241
|
-
});
|
|
242
|
-
setAuthTokens(res.data.access_token, res.data.refresh_token);
|
|
243
|
-
applyUser(res.data.user);
|
|
244
|
-
closeModal();
|
|
258
|
+
await client.auth.emailRequestOtp({ email: email.trim() });
|
|
259
|
+
setOtp('');
|
|
260
|
+
setPasswordSignup(true);
|
|
261
|
+
setStep('email-otp-verify');
|
|
245
262
|
} catch (err) {
|
|
246
263
|
setError(mapEmailError(err, t));
|
|
247
264
|
} finally {
|
|
@@ -291,6 +308,7 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
|
|
|
291
308
|
setStep('email-otp');
|
|
292
309
|
setOtp('');
|
|
293
310
|
setVerifiedToken('');
|
|
311
|
+
setPasswordSignup(false);
|
|
294
312
|
setFirstName('');
|
|
295
313
|
setLastName('');
|
|
296
314
|
setEmail('');
|
|
@@ -303,16 +321,19 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
|
|
|
303
321
|
setStep('email-otp');
|
|
304
322
|
setOtp('');
|
|
305
323
|
setVerifiedToken('');
|
|
324
|
+
setPasswordSignup(false);
|
|
306
325
|
setError(null);
|
|
307
326
|
};
|
|
308
327
|
|
|
309
328
|
const goToEmailLogin = (): void => {
|
|
310
329
|
setStep('email-login');
|
|
330
|
+
setPasswordSignup(false);
|
|
311
331
|
setError(null);
|
|
312
332
|
};
|
|
313
333
|
|
|
314
334
|
const goToEmailRegister = (): void => {
|
|
315
335
|
setStep('email-register');
|
|
336
|
+
setPasswordSignup(false);
|
|
316
337
|
setError(null);
|
|
317
338
|
};
|
|
318
339
|
|
package/package.json
CHANGED