@opexa/portal-components 0.0.908 → 0.0.909
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.
|
@@ -5,6 +5,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
5
5
|
import dynamic from 'next/dynamic';
|
|
6
6
|
import Image from 'next/image';
|
|
7
7
|
import { useRouter } from 'next/navigation';
|
|
8
|
+
import { useState } from 'react';
|
|
8
9
|
import { Controller, useForm } from 'react-hook-form';
|
|
9
10
|
import { twMerge } from 'tailwind-merge';
|
|
10
11
|
import invariant from 'tiny-invariant';
|
|
@@ -51,6 +52,7 @@ export function NameAndPasswordSignIn() {
|
|
|
51
52
|
registerBiometrics: ctx.registerBiometrics,
|
|
52
53
|
disclaimer: ctx.disclaimer,
|
|
53
54
|
})));
|
|
55
|
+
const [formType, setFormType] = useState('NAME_AND_PASSWORD');
|
|
54
56
|
const signInMutation = useSignInMutation({
|
|
55
57
|
onSuccess: async (authenticator) => {
|
|
56
58
|
if (authenticator) {
|
|
@@ -130,7 +132,9 @@ export function NameAndPasswordSignIn() {
|
|
|
130
132
|
onError(err) {
|
|
131
133
|
toaster.error({
|
|
132
134
|
title: 'Sign In Failed',
|
|
133
|
-
description:
|
|
135
|
+
description: formType === 'NAME_AND_PASSWORD'
|
|
136
|
+
? err.message
|
|
137
|
+
: 'Invalid security question',
|
|
134
138
|
});
|
|
135
139
|
},
|
|
136
140
|
});
|
|
@@ -256,6 +260,7 @@ export function NameAndPasswordSignIn() {
|
|
|
256
260
|
: null;
|
|
257
261
|
return (_jsxs(_Fragment, { children: [_jsxs("form", { className: "mt-3xl", onSubmit: form.handleSubmit((data) => {
|
|
258
262
|
if (!signInMutation.data) {
|
|
263
|
+
setFormType('NAME_AND_PASSWORD');
|
|
259
264
|
signInMutation.mutateAsync({
|
|
260
265
|
type: 'NAME_AND_PASSWORD',
|
|
261
266
|
name: data.name,
|
|
@@ -263,6 +268,7 @@ export function NameAndPasswordSignIn() {
|
|
|
263
268
|
});
|
|
264
269
|
}
|
|
265
270
|
else {
|
|
271
|
+
setFormType('SECURITY_QUESTION');
|
|
266
272
|
authenticateMutation.mutateAsync({
|
|
267
273
|
type: 'SECURITY_QUESTION',
|
|
268
274
|
token: signInMutation.data.token,
|