bugfix - verify email

This commit is contained in:
James Wyndham 2024-06-05 15:56:59 +08:00
parent a57af24533
commit bd6ca82bb3
3 changed files with 10 additions and 3 deletions

View File

@ -134,7 +134,8 @@ export async function login(formData: { email: string; password: string }) {
} }
return { success: true, error: "Failed to log in", token: token, data: data }; return { success: true, error: "Failed to log in", token: token, data: data };
} catch (error) { } catch (error) {
throw error; console.log(error)
return JSON.parse(JSON.stringify(error))
} }
} }

View File

@ -24,12 +24,15 @@ function ModalSignIn() {
const onSubmit = async (data: any) => { const onSubmit = async (data: any) => {
try { try {
//login user //login user
const auth = (await login({ email: data.email, password: data.password }))
if ( if (
(await login({ email: data.email, password: data.password })).success auth.success
) { ) {
reset(); reset();
document.getElementById("sign-in-modal")?.click(); document.getElementById("sign-in-modal")?.click();
router.push("/account"); router.push("/account");
} else {
throw new Error(auth.response.message)
} }
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {

View File

@ -69,8 +69,9 @@ function ModalSignUp({
.collection("user") .collection("user")
.create({ ...data, organisation: organisation.id }); .create({ ...data, organisation: organisation.id });
//login user //login user
const auth = (await login({ email: data.email, password: data.password }))
if ( if (
(await login({ email: data.email, password: data.password })).success auth.success
) { ) {
reset(); reset();
document.getElementById("sign-up-modal")?.click(); document.getElementById("sign-up-modal")?.click();
@ -82,6 +83,8 @@ function ModalSignUp({
price price
? generateCheckoutPage(JSON.parse(price), type ?? "") ? generateCheckoutPage(JSON.parse(price), type ?? "")
: router.push("/account"); : router.push("/account");
} else {
throw new Error(auth.response.message)
} }
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {