Skip to content

Commit

Permalink
added login with google authentication (#133)
Browse files Browse the repository at this point in the history
* added login with google authentication

* updated snapshot tests

* fixed import error

Co-authored-by: allan <[email protected]>
  • Loading branch information
Imanzuher and AllanSaleh authored Nov 28, 2022
1 parent 517588d commit e5cbb29
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 123 deletions.
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function App() {
<Route path="/roadmap" element={<RoadMaps />} />
<Route path="/jobs" element={<CombiningFilterComponents />} />
<Route path="/profile" element={<ProfilePage />} />
<Route path="/profile-edit" element={<ProfileEdit/>} />
<Route path="/profile-edit" element={<ProfileEdit />} />
<Route path="/contact" element={<ContactPage />} />
</Routes>
<Footer />
Expand Down
51 changes: 0 additions & 51 deletions src/components/Contact/Contact.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/components/Contact/__Test__/Contact.test.js

This file was deleted.

56 changes: 0 additions & 56 deletions src/components/Contact/__Test__/__snapshots__/Contact.test.js.snap

This file was deleted.

10 changes: 9 additions & 1 deletion src/components/Login/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/* eslint-disable no-console */
import { useNavigate, Link } from "react-router-dom";
import { useForm } from "react-hook-form";
import { Link } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faGoogle } from "@fortawesome/free-brands-svg-icons";
import { auth, google, signInWithPopup } from "../../firebase";

function Login() {
const navigate = useNavigate();
const login = async (provider) => {
const result = await signInWithPopup(auth, provider);
console.log(result);
navigate("/");
};
const {
register,
formState: { errors },
Expand Down Expand Up @@ -77,6 +84,7 @@ function Login() {
<div>
<button
type="button"
onClick={() => login(google)}
className=" text-black border-t-2 border-l-2 border-r-4 border-b-4 border-black py-0.5 px-8 rounded-lg bg-white hover:shadow-md"
>
<FontAwesomeIcon
Expand Down
1 change: 0 additions & 1 deletion src/components/Login/__test__/Login.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import renderer from "react-test-renderer";
import { MemoryRouter } from "react-router-dom";

import Login from "../Login";

it("renders correctly when the component matches the snapshot", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ exports[`renders correctly when the component matches the snapshot 1`] = `
<div>
<button
className=" text-black border-t-2 border-l-2 border-r-4 border-b-4 border-black py-0.5 px-8 rounded-lg bg-white hover:shadow-md"
onClick={[Function]}
type="button"
>
<svg
Expand Down
1 change: 0 additions & 1 deletion src/components/signup/SignUp.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-alert */
/* eslint-disable no-console */
import React from "react";
import { useForm } from "react-hook-form";
import { Link, useNavigate } from "react-router-dom";
import { useDispatch } from "react-redux";
Expand Down
5 changes: 5 additions & 0 deletions src/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
} from "firebase/firestore";
import {
getAuth,
GoogleAuthProvider,
signInWithPopup,
createUserWithEmailAndPassword,
updateProfile,
onAuthStateChanged,
Expand All @@ -34,9 +36,12 @@ const firebaseConfig = {

const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const google = new GoogleAuthProvider();
const auth = getAuth();

export {
signInWithPopup,
google,
db,
collection,
getDocs,
Expand Down

0 comments on commit e5cbb29

Please sign in to comment.