-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add google oauth (#101) close issue#72
* added google oauth * made UI changes * ticket is editable * resolved comments * clean * corrections
- Loading branch information
Showing
10 changed files
with
443 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
MONGODB_URI=mongodb+srv://yourUSER:[email protected]/MondayClone | ||
CLIENT_ID=<google-oauth-clientid> | ||
GOOGLE_CLIENT_SECRET=<google-oauth-clientsecret> | ||
REDIS_HOST=127.0.0.1 # Replace with your Redis server's IP or hostname | ||
REDIS_PORT=6379 # Default Redis port | ||
REDIS_PORT=6379 # Default Redis port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import NextAuth from "next-auth"; | ||
import GoogleProvider from "next-auth/providers/google"; | ||
|
||
export const authOptions = { | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET, | ||
}), | ||
], | ||
callbacks: { | ||
async session({ session, token }) { | ||
session.user.id = token.sub; | ||
return session; | ||
}, | ||
}, | ||
}; | ||
|
||
const handler = NextAuth(authOptions); | ||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import { signIn } from "next-auth/react"; | ||
|
||
const SignInPage = () => { | ||
const handleGoogleSignIn = () => { | ||
signIn("google", { callbackUrl: "/" }); | ||
}; | ||
|
||
return ( | ||
<div className="flex justify-center items-center min-h-screen bg-dark gray-100"> | ||
<div className="p-8 border rounded-lg shadow-lg w-96 bg-dark gray"> | ||
<h1 className="text-3xl mb-6 text-center font-semibold text-white-700">Sign In</h1> | ||
<button | ||
onClick={handleGoogleSignIn} | ||
className="w-full bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 text-white p-4 rounded-lg flex items-center justify-center space-x-3 transform transition duration-300 hover:scale-105 shadow-lg" | ||
> | ||
<img | ||
src="/googlelogo.png" | ||
alt="Google" | ||
className="w-6 h-6" | ||
/> | ||
<span className="font-medium">Sign in with Google</span> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SignInPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.