FEAT: Added Google OAuth login feature to sign up as well as login

This commit is contained in:
JustIceO7
2025-02-11 02:22:27 +00:00
parent 07652eed0d
commit 0984271a11
11 changed files with 128 additions and 56 deletions

View File

@@ -2,6 +2,7 @@ import React, { useState } from "react";
import Input from "../Layout/Input";
import Button from "../Layout/Button";
import { useAuth } from "../../context/AuthContext";
import GoogleLogin from "./OAuth";
interface LoginFormData {
username: string;
@@ -133,6 +134,7 @@ const LoginForm: React.FC<SubmitProps> = ({ onSubmit }) => {
/>
<Button type="submit">Login</Button>
<GoogleLogin />
</form>
</div>
</>

View File

@@ -0,0 +1,23 @@
import { useEffect } from "react";
export default function GoogleLogin() {
const handleLoginClick = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
window.location.href = "/api/login/google";
};
return (
<div>
<button
onClick={handleLoginClick}
className="flex items-center justify-start bg-white text-gray-600 font-semibold py-1 px-2 rounded shadow-md w-[220px] hover:bg-gray-100 active:bg-gray-200">
<img
src="../../../images/icons/google-icon.png"
alt="Google logo"
className="w-8 h-8 mr-2"
/>
<span className="flex-grow">Sign in with Google</span>
</button>
</div>
);
}