forked from Transparency/kgroad-frontend2
fixed bug with sign-in
This commit is contained in:
parent
7bc3e2ccb5
commit
7d36510a9b
@ -1,5 +1,13 @@
|
|||||||
const page = () => {
|
"use client";
|
||||||
return <div>page</div>;
|
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;
|
||||||
|
@ -40,6 +40,8 @@ const BreadCrumbs: React.FC<IBreadcrumbsProps> = ({
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
{routes.map((route, i, array) => {
|
{routes.map((route, i, array) => {
|
||||||
|
if (routes.length === 1 && routes[0] === "profile")
|
||||||
|
return null;
|
||||||
if (parseInt(route)) {
|
if (parseInt(route)) {
|
||||||
if (routes[0] === "news") {
|
if (routes[0] === "news") {
|
||||||
return <span key={query}>{query}</span>;
|
return <span key={query}>{query}</span>;
|
||||||
|
@ -70,12 +70,12 @@ export const authConfig: AuthOptions = {
|
|||||||
|
|
||||||
const res = await apiInstance.post("/users/login/", data);
|
const res = await apiInstance.post("/users/login/", data);
|
||||||
|
|
||||||
if (![200, 201].includes(res.status)) {
|
if ([200, 201].includes(res.status)) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = res.data;
|
const user = res.data;
|
||||||
return user;
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
GoogleProvider({
|
GoogleProvider({
|
||||||
@ -90,11 +90,7 @@ export const authConfig: AuthOptions = {
|
|||||||
strategy: "jwt",
|
strategy: "jwt",
|
||||||
},
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
async signIn({ account, profile, user }) {
|
async signIn({ account, user }) {
|
||||||
if (!profile?.email) {
|
|
||||||
throw new Error("No Profile");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (account?.provider === "google") {
|
if (account?.provider === "google") {
|
||||||
const data = {
|
const data = {
|
||||||
auth_token: account?.id_token,
|
auth_token: account?.id_token,
|
||||||
|
@ -44,9 +44,9 @@ const ConfirmCode: React.FC<IConfirmCodeProps> = ({
|
|||||||
);
|
);
|
||||||
router.push("/sign-in/reset-code");
|
router.push("/sign-in/reset-code");
|
||||||
}
|
}
|
||||||
|
setLoader(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError("An error ocured");
|
setError("An error ocured");
|
||||||
} finally {
|
|
||||||
setLoader(false);
|
setLoader(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,7 @@ const SendEmail: React.FC<ISendEmailProps> = ({
|
|||||||
|
|
||||||
<form onSubmit={handleSubmit} className="send-email">
|
<form onSubmit={handleSubmit} className="send-email">
|
||||||
<AuthInput
|
<AuthInput
|
||||||
type="text"
|
type="email"
|
||||||
name="email"
|
name="email"
|
||||||
label="Email"
|
label="Email"
|
||||||
error={error}
|
error={error}
|
||||||
|
@ -48,6 +48,8 @@ const SignInForm = () => {
|
|||||||
|
|
||||||
setLoader(false);
|
setLoader(false);
|
||||||
|
|
||||||
|
console.log(res);
|
||||||
|
|
||||||
if (res?.ok && !res.error) {
|
if (res?.ok && !res.error) {
|
||||||
router.push("/profile/personal");
|
router.push("/profile/personal");
|
||||||
} else if (res?.status.toString().slice(0, 1) === "4") {
|
} else if (res?.status.toString().slice(0, 1) === "4") {
|
||||||
|
Loading…
Reference in New Issue
Block a user