This commit is contained in:
@@ -42,7 +42,7 @@ export default function ResetPasswordForm() {
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
await apiCreateOTP(email);
|
||||
await apiCreateOTP(email, 1);
|
||||
toast.success("Mã OTP đã được gửi đến email của bạn!");
|
||||
setStep(2);
|
||||
} catch (error) {
|
||||
@@ -69,7 +69,7 @@ export default function ResetPasswordForm() {
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
const verifyRes = await apiVerifyOTP(email, otp);
|
||||
const verifyRes = await apiVerifyOTP(email, otp, 1);
|
||||
const tokenId = verifyRes?.data?.token_id;
|
||||
|
||||
if (!tokenId) {
|
||||
|
||||
@@ -115,9 +115,10 @@ export default function SignInForm() {
|
||||
// Redirect back to the same origin (avoid hard-coded port/env mismatches).
|
||||
const redirectUrl =
|
||||
typeof window !== "undefined" ? window.location.origin : HOME_URL;
|
||||
window.location.href = `${API.Auth.GOOGLE_LOGIN}?redirect=${encodeURIComponent(
|
||||
const googleUrl = `${API.Auth.GOOGLE_LOGIN}?redirect=${encodeURIComponent(
|
||||
redirectUrl
|
||||
)}`;
|
||||
router.push(googleUrl);
|
||||
}}
|
||||
className="inline-flex items-center justify-center gap-3 py-3 text-sm font-normal text-gray-700 transition-colors bg-gray-100 rounded-lg px-7 hover:bg-gray-200 hover:text-gray-800 dark:bg-white/5 dark:text-white/90 dark:hover:bg-white/10"
|
||||
>
|
||||
|
||||
@@ -166,9 +166,10 @@ export default function SignUpForm() {
|
||||
// Redirect back to the same origin (avoid hard-coded port/env mismatches).
|
||||
const redirectUrl =
|
||||
typeof window !== "undefined" ? window.location.origin : HOME_URL;
|
||||
window.location.href = `${API.Auth.GOOGLE_LOGIN}?redirect=${encodeURIComponent(
|
||||
const googleUrl = `${API.Auth.GOOGLE_LOGIN}?redirect=${encodeURIComponent(
|
||||
redirectUrl
|
||||
)}`;
|
||||
router.push(googleUrl);
|
||||
}}
|
||||
className="inline-flex items-center justify-center gap-3 py-3 text-sm font-normal text-gray-700 transition-colors bg-gray-100 rounded-lg px-7 hover:bg-gray-200 hover:text-gray-800 dark:bg-white/5 dark:text-white/90 dark:hover:bg-white/10"
|
||||
>
|
||||
|
||||
@@ -2,8 +2,7 @@ import api from "@/config/config";
|
||||
import { API } from "../../api";
|
||||
import { clearStoredTokens, extractTokensFromResponsePayload, setStoredTokens } from "@/auth/tokenStore";
|
||||
|
||||
export const apiCreateOTP = async (email: string) => {
|
||||
const token_type = 2;
|
||||
export const apiCreateOTP = async (email: string, token_type: number = 2) => {
|
||||
const response = await api.post(API.Auth.CREATEOTP, {
|
||||
email,
|
||||
token_type
|
||||
@@ -11,8 +10,8 @@ export const apiCreateOTP = async (email: string) => {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiVerifyOTP = async (email: string, token: string) => {
|
||||
const body = { email, token, token_type: 2 };
|
||||
export const apiVerifyOTP = async (email: string, token: string, token_type: number = 2) => {
|
||||
const body = { email, token, token_type };
|
||||
const response = await api.post(API.Auth.VERIFYOTP, body);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user