UPDATE: fix buyg+
This commit is contained in:
@@ -42,7 +42,7 @@ export default function ResetPasswordForm() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await apiCreateOTP(email);
|
await apiCreateOTP(email, 1);
|
||||||
toast.success("Mã OTP đã được gửi đến email của bạn!");
|
toast.success("Mã OTP đã được gửi đến email của bạn!");
|
||||||
setStep(2);
|
setStep(2);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -69,7 +69,7 @@ export default function ResetPasswordForm() {
|
|||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const verifyRes = await apiVerifyOTP(email, otp);
|
const verifyRes = await apiVerifyOTP(email, otp, 1);
|
||||||
const tokenId = verifyRes?.data?.token_id;
|
const tokenId = verifyRes?.data?.token_id;
|
||||||
|
|
||||||
if (!tokenId) {
|
if (!tokenId) {
|
||||||
|
|||||||
@@ -115,9 +115,10 @@ export default function SignInForm() {
|
|||||||
// Redirect back to the same origin (avoid hard-coded port/env mismatches).
|
// Redirect back to the same origin (avoid hard-coded port/env mismatches).
|
||||||
const redirectUrl =
|
const redirectUrl =
|
||||||
typeof window !== "undefined" ? window.location.origin : HOME_URL;
|
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
|
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"
|
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).
|
// Redirect back to the same origin (avoid hard-coded port/env mismatches).
|
||||||
const redirectUrl =
|
const redirectUrl =
|
||||||
typeof window !== "undefined" ? window.location.origin : HOME_URL;
|
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
|
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"
|
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 { API } from "../../api";
|
||||||
import { clearStoredTokens, extractTokensFromResponsePayload, setStoredTokens } from "@/auth/tokenStore";
|
import { clearStoredTokens, extractTokensFromResponsePayload, setStoredTokens } from "@/auth/tokenStore";
|
||||||
|
|
||||||
export const apiCreateOTP = async (email: string) => {
|
export const apiCreateOTP = async (email: string, token_type: number = 2) => {
|
||||||
const token_type = 2;
|
|
||||||
const response = await api.post(API.Auth.CREATEOTP, {
|
const response = await api.post(API.Auth.CREATEOTP, {
|
||||||
email,
|
email,
|
||||||
token_type
|
token_type
|
||||||
@@ -11,8 +10,8 @@ export const apiCreateOTP = async (email: string) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiVerifyOTP = async (email: string, token: string) => {
|
export const apiVerifyOTP = async (email: string, token: string, token_type: number = 2) => {
|
||||||
const body = { email, token, token_type: 2 };
|
const body = { email, token, token_type };
|
||||||
const response = await api.post(API.Auth.VERIFYOTP, body);
|
const response = await api.post(API.Auth.VERIFYOTP, body);
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user