fixed bug with sign-in

This commit is contained in:
Alibek 2024-03-13 16:48:13 +06:00
parent 7bc3e2ccb5
commit 7d36510a9b
6 changed files with 22 additions and 14 deletions

View File

@ -1,5 +1,13 @@
const page = () => {
return <div>page</div>;
"use client";
import { useRouter } from "@/shared/config/navigation";
import { useEffect } from "react";
const Profile = () => {
const router = useRouter();
useEffect(() => {
router.push("/profile/personal");
}, []);
return <></>;
};
export default page;
export default Profile;

View File

@ -40,6 +40,8 @@ const BreadCrumbs: React.FC<IBreadcrumbsProps> = ({
</Link>
)}
{routes.map((route, i, array) => {
if (routes.length === 1 && routes[0] === "profile")
return null;
if (parseInt(route)) {
if (routes[0] === "news") {
return <span key={query}>{query}</span>;

View File

@ -70,12 +70,12 @@ export const authConfig: AuthOptions = {
const res = await apiInstance.post("/users/login/", data);
if (![200, 201].includes(res.status)) {
return null;
if ([200, 201].includes(res.status)) {
const user = res.data;
return user;
}
const user = res.data;
return user;
return null;
},
}),
GoogleProvider({
@ -90,11 +90,7 @@ export const authConfig: AuthOptions = {
strategy: "jwt",
},
callbacks: {
async signIn({ account, profile, user }) {
if (!profile?.email) {
throw new Error("No Profile");
}
async signIn({ account, user }) {
if (account?.provider === "google") {
const data = {
auth_token: account?.id_token,

View File

@ -44,9 +44,9 @@ const ConfirmCode: React.FC<IConfirmCodeProps> = ({
);
router.push("/sign-in/reset-code");
}
setLoader(false);
} catch (error) {
setError("An error ocured");
} finally {
setLoader(false);
}
};

View File

@ -57,7 +57,7 @@ const SendEmail: React.FC<ISendEmailProps> = ({
<form onSubmit={handleSubmit} className="send-email">
<AuthInput
type="text"
type="email"
name="email"
label="Email"
error={error}

View File

@ -48,6 +48,8 @@ const SignInForm = () => {
setLoader(false);
console.log(res);
if (res?.ok && !res.error) {
router.push("/profile/personal");
} else if (res?.status.toString().slice(0, 1) === "4") {