Commit 3d924a35 by Arjun Jhukal

updated the device_id at the auth route

parent fdb4bb00
"use client";
import { useSeon } from '@/app/SeonProvider';
import GlassWrapper from '@/components/molecules/GlassWrapper';
import { useAppDispatch } from '@/hooks/hook';
import { PATH } from '@/routes/PATH';
import { useSendVerificationLinkAgainMutation, useVerifyEmailMutation } from '@/services/authApi';
import { showToast, ToastVariant } from '@/slice/toastSlice';
import { Box, Button } from '@mui/material';
import { Button } from '@mui/material';
import Image from 'next/image';
import Link from 'next/link';
import { useRouter, useSearchParams } from 'next/navigation';
import React, { Suspense } from 'react';
import { Suspense } from 'react';
function VerifyEmailContent() {
const router = useRouter();
......@@ -21,6 +21,8 @@ function VerifyEmailContent() {
const [verifyEmail, { isLoading }] = useVerifyEmailMutation();
const dispatch = useAppDispatch();
const { deviceId, loading } = useSeon();
const handleLinkResend = async () => {
try {
const response = await sendEmailVerificationAgain({ email: email || "" }).unwrap();
......@@ -44,7 +46,7 @@ function VerifyEmailContent() {
const handleEmailVerification = async () => {
try {
const response = await verifyEmail({ id: id || "", hash: hash || "" }).unwrap();
const response = await verifyEmail({ id: id || "", hash: hash || "", device_id: deviceId || "" }).unwrap();
dispatch(
showToast({
message: response?.message || "Account verified successfully",
......
'use client';
import { useSeon } from '@/app/SeonProvider';
import PasswordField from '@/components/molecules/PasswordField';
import { useAppDispatch } from '@/hooks/hook';
import { PATH } from '@/routes/PATH';
......@@ -117,6 +118,7 @@ export default function RegisterPage() {
pob: '',
agree: true
}
const { deviceId, loading } = useSeon();
const { handleSubmit, handleBlur, handleChange, errors, dirty, values, touched, setFieldValue, setFieldTouched } = useFormik(
{
initialValues,
......@@ -137,7 +139,8 @@ export default function RegisterPage() {
dob: formattedDob,
city: values.city,
pob: values.pob,
agree: values.agree
agree: values.agree,
device_id: deviceId
}).unwrap();
dispatch(
......
......@@ -11,14 +11,14 @@ export const authApi = createApi({
query: ({ email,
username,
password,
password_confirmation, first_name, middle_name, last_name, phone, photoid_number, dob, city, pob, agree }) => ({
password_confirmation, first_name, middle_name, last_name, phone, photoid_number, dob, city, pob, agree,device_id }) => ({
url: `/api/auth/register`,
method: "POST",
body: {
email,
username,
password,
password_confirmation, first_name, middle_name, last_name, phone, photoid_number, dob, city, pob, agree
password_confirmation, first_name, middle_name, last_name, phone, photoid_number, dob, city, pob, agree,device_id
},
}),
......@@ -37,11 +37,11 @@ export const authApi = createApi({
body: { email },
})
}),
verifyEmail: builder.mutation<GlobalResponse, { id: string; hash: string }>({
query: ({ id, hash }) => ({
verifyEmail: builder.mutation<GlobalResponse, { id: string; hash: string,device_id:string }>({
query: ({ id, hash ,device_id}) => ({
url: "/api/auth/verify-email",
method: "POST",
body: { id, hash },
body: { id, hash,device_id},
})
}),
forgotPassword: builder.mutation<GlobalResponse, { email: string }>({
......
......@@ -18,9 +18,8 @@ export const baseQuery = fetchBaseQuery({
headers.set("Accept", "application/json");
console.log("deviceId", globalDeviceId)
if (globalDeviceId) {
headers.set("Device_id", globalDeviceId);
headers.set("X-Device-Id", globalDeviceId);
}
if (token) {
headers.set("Authorization", `Bearer ${token}`);
......
......@@ -40,4 +40,5 @@ export interface RegisterProps extends LoginProps {
city: string;
pob: string;
agree: boolean;
device_id?: string;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment