Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add firebase google authentication #1137

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Express_js_Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ app.get("/allData", async (req, res) => {
("[email protected]", "priyansh!", "priyansh mishra", "5347658679", "2567","some feedback");`;



let output = await db.all(bringAllData);
console.log("table created");

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
"homepage": ".",
"name": "website",
"version": "0.1.0",


"proxy": "https://umatter.onrender.com",

"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/react": "^18.2.7",
"@types/react-dom": "^18.2.4",
"dotenv": "^16.3.1",
"firebase": "^10.1.0",
"framer-motion": "^10.12.16",
"react": "^18.2.0",
"react-bootstrap": "^2.7.4",
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Signin/SigninElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export const FormContainer = styled.div`
export const SignInContainer = styled.div`
width: 55%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100%;
Expand All @@ -193,7 +194,7 @@ export const RightContainer = styled.div`

export const SignInForm = styled.form`
min-width: 100%;
height: 100%;
height: 70%;
display: flex;
flex-direction: column;
justify-content: center;
Expand Down
163 changes: 141 additions & 22 deletions src/Components/Signin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@
import React from "react";
import { useNavigate } from "react-router-dom";
// import DarkMode from '../DarkMode/DarkMode';
import { signInWithPopup } from "firebase/auth";
import { useState } from "react";
import { NavLink } from "react-router-dom";
import { auth, provider } from "../../firebase-config";
import SignInImg from "../../images/SignIn.webp";
import {
NewContainer,
FormContainer,
SignInContainer,
RightContainer,
SignInForm,
SignInButton,
RightHeading,
RightPara,
SignInInput,
SignInLabel,
SignInh1,
CheckBox,
RememberMe,
ForgotPassword,
PasswordContainer,
FormContainer,
Image
// Icons,
// FormButton,
Expand All @@ -29,10 +22,120 @@ import {
// FormLabel,
// FormWrap,
// Text,
,




































































































NewContainer,
PasswordContainer,
RememberMe,
RightContainer,
RightHeading,
RightPara,
SignInButton,
SignInContainer,
SignInForm,
SignInInput,
SignInLabel,
SignInh1
} from "./SigninElements";
import SignInImg from "../../images/SignIn.webp";
import { useState } from "react";
import { NavLink } from "react-router-dom";
// import Navbar from "../Navbar";

const SignIn = () => {
Expand Down Expand Up @@ -98,6 +201,17 @@ const SignIn = () => {
);
};

// Firebase google authentication
const handleGoogleLogin = async () => {
try {
const user = await signInWithPopup(auth, provider);
localStorage.setItem("authorizationToken", user.user.accessToken);
localStorage.setItem("username", user.user.email);
} catch (err) {
console.log(err.message);
}
}

return (
// <>
// {/* <DarkMode/> */}
Expand Down Expand Up @@ -197,7 +311,7 @@ const SignIn = () => {
<NewContainer>
<FormContainer>
<SignInContainer>
<SignInForm onSubmit={sendPostRequest} action="#">
<SignInForm onSubmit={sendPostRequest}>
<SignInh1>Sign in</SignInh1>
<SignInLabel htmlFor="email">Email</SignInLabel>
<SignInInput
Expand All @@ -216,7 +330,7 @@ const SignIn = () => {
placeholder="at least 8 characters"
require
/>
{passwordType === "password" ? (
{passwordType === "password" ? (
<i
className="fa-solid fa-eye-slash"
id="eye"
Expand Down Expand Up @@ -254,12 +368,17 @@ const SignIn = () => {
<NavLink to="/signin/forgotPassword">
<ForgotPassword>Forgot password?</ForgotPassword>
</NavLink>
<label style={{ fontSize: '14px', marginLeft: '-25px',marginTop: '10px', display: 'block' , color: 'green'}}>Don't have an account ? </label>
<NavLink to="/signup" style={{ fontSize: '14px', marginTop: '-20px' ,marginLeft: '200px' }}>
<label style={{ fontSize: '14px', marginLeft: '-25px', marginTop: '10px', display: 'block', color: 'green' }}>Don't have an account ? </label>
<NavLink to="/signup" style={{ fontSize: '14px', marginTop: '-20px', marginLeft: '200px' }}>
SignUp
</NavLink>
</SignInForm>
</NavLink>
</SignInForm>
<div className='flex relative mt-10 w-[80%] md:w-[60%]' onClick={handleGoogleLogin}>
<button className='py-3 rounded-xl text-black font-semibold w-[100%] border-2 border-black'>Sign in with Google</button>
<img src={require('../../assests/googleLogo.png')} className='w-10 absolute top-1.5 left-4' alt='google' />
</div>
</SignInContainer>

<RightContainer>
<RightHeading>Hello, Friend!</RightHeading>
<RightPara>Enter your details and let's get started.</RightPara>
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Signup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const SignUp = () => {
const [data, setData] = useState({});
const [trackState, setTrackState] = useState(false);



// Use for internation country code selector
const [value, setValue] = useState();

Expand Down
Binary file added src/assests/googleLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/firebase-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAuth, GoogleAuthProvider } from "firebase/auth";

// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: `${process.env.REACT_APP_APIKEYURL}`,
authDomain: `${process.env.REACT_APP_AUTHDOMAIN}`,
projectId: `${process.env.REACT_APP_PROJECTID}`,
storageBucket: `${process.env.REACT_APP_STORAGEBUCKET}`,
messagingSenderId: `${process.env.REACT_APP_MESSAGEINGSENDERID}`,
appId: `${process.env.REACT_APP_APIID}`,
measurementId: `${process.env.REACT_APP_MEASUREMENTID}`,
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

export const auth = getAuth(app);
export const provider = new GoogleAuthProvider();
Loading