login with google

This commit is contained in:
Mac mini
2026-03-31 15:52:41 +07:00
parent 23fd45bda2
commit 59f64bc6a0
4 changed files with 38 additions and 19 deletions

View File

@@ -58,16 +58,13 @@ const [showPassword, setShowPassword] = useState(false);
try {
setLoading(true);
const res = await apiSignIn(formData);
console.log("API Sign In Response:", res);
const data = await api.get(API.User.CURRENT);
console.log("Current User:", data);
if (res.status === true) {
toast.success('Đăng nhập thành công!');
const data = await apiGetCurrentUser();
console.log("Current User:", data);
}else{
toast.error('Email hoặc mật khẩu không đúng.');
}
@@ -103,7 +100,7 @@ const [showPassword, setShowPassword] = useState(false);
</div>
<div>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-5">
<button 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">
<button onClick={() => (window.location.href = API.Auth.GOOGLE_LOGIN)} 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">
<svg
width="20"
height="20"
@@ -130,7 +127,7 @@ const [showPassword, setShowPassword] = useState(false);
</svg>
Sign in with Google
</button>
<button 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">
{/* <button 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">
<svg
width="21"
className="fill-current"
@@ -142,7 +139,7 @@ const [showPassword, setShowPassword] = useState(false);
<path d="M15.6705 1.875H18.4272L12.4047 8.75833L19.4897 18.125H13.9422L9.59717 12.4442L4.62554 18.125H1.86721L8.30887 10.7625L1.51221 1.875H7.20054L11.128 7.0675L15.6705 1.875ZM14.703 16.475H16.2305L6.37054 3.43833H4.73137L14.703 16.475Z" />
</svg>
Sign in with X
</button>
</button> */}
</div>
<div className="relative py-3 sm:py-5">
<div className="absolute inset-0 flex items-center">