Skip to content

Commit

Permalink
Merge pull request #776 from haseebzaki-07/new_branch_7
Browse files Browse the repository at this point in the history
Add google signup on signup page.
  • Loading branch information
manikumarreddyu authored Nov 4, 2024
2 parents 692f117 + 9ed93fb commit f43491c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions backend/routes/googleauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,16 @@ router.get(
}
);

router.get('/auth/logout', (req, res) => {
req.logout(err => {
if (err) {
return next(err);
}
req.session.destroy(() => {
res.clearCookie('connect.sid');
res.redirect('https://agro-tech-ai.vercel.app/');
});
});
});

module.exports = router;
15 changes: 13 additions & 2 deletions frontend/src/components/SignUpPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toast, ToastContainer } from "react-toastify";
import signupImage from "../assets/SignUpImage.png";
import eyeIcon from "../assets/icons/eye.svg";
import eyeSlashIcon from "../assets/icons/eye-slash.svg";

import googleIcon from "../assets/icons/icons8-google.svg"; // Google icon for the button
const SignUpPage = () => {
const navigate = useNavigate();
const [password, setPassword] = useState("");
Expand Down Expand Up @@ -52,7 +52,7 @@ const SignUpPage = () => {

try {
const response = await axios.post(
"https://agro-tech-ai-backend-teal.vercel.app/auth/signup",
"http://localhost:8080/auth/signup",
{
firstName,
lastName,
Expand All @@ -69,6 +69,9 @@ const SignUpPage = () => {
);
}
};
const handleGoogleSignIn = () => {
window.location.href = "https://agro-tech-ai-backend-teal.vercel.app/auth/google";
};

return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-r from-blue-400 to-green-500 mt-10">
Expand Down Expand Up @@ -228,6 +231,14 @@ const SignUpPage = () => {
>
Sign Up
</button>
<button
onClick={handleGoogleSignIn}
className="w-full mt-4 py-2 flex items-center justify-center bg-white text-gray-700 border border-gray-300 rounded-md font-bold transform transition duration-300 hover:scale-105"
>
<img src={googleIcon} alt="Google" className="w-6 h-6 mr-2" />
Sign in with Google
</button>

</div>
</form>
<p className="text-center text-sm mt-4">
Expand Down

0 comments on commit f43491c

Please sign in to comment.