Skip to content

Commit

Permalink
Merge pull request #9 from brandontor/workflow
Browse files Browse the repository at this point in the history
added logout functionality
  • Loading branch information
brandontor authored Oct 31, 2021
2 parents b5909fe + 1a74d16 commit d9ec4f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 8 additions & 4 deletions components/SidebarFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React from 'react'
import Button from '@material-ui/core/Button'
import Avatar from '@material-ui/core/Avatar'
import style from './SidebarFrame.module.css'
import { useContext } from 'react';
import { UserContext } from '../lib/context';
import { googleSignOut } from "../lib/auth.js";
import { signOutUser } from "../lib/auth";
import { useAuthState } from 'react-firebase-hooks/auth';
import { auth } from '../lib/firebaseInit';
import { googleSignIn } from "../lib/auth"

function SidebarFrame() {

Expand All @@ -33,7 +32,12 @@ function SidebarFrame() {
<h3 className={style.h3}>{
user == null ? undefined : user.displayName
}</h3>
<Button variant="contained" style={buttonStyles} onClick={googleSignOut}>Log Out</Button>

{user
?
<Button variant="contained" style={buttonStyles} onClick={signOutUser}>Log Out</Button>
:
<Button variant="contained" style={buttonStyles} onClick={googleSignIn}>Log In</Button> }
</div>
</div>
)
Expand Down
4 changes: 1 addition & 3 deletions lib/auth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { auth } from "./firebaseInit";
import { GoogleAuthProvider, signInWithPopup, signOut} from "firebase/auth";


// Sign in with popup && Google as the provider
const googleProvider = new GoogleAuthProvider();

Expand All @@ -24,5 +23,4 @@ export const signOutUser = async () => {
.catch((error) => {
console.error("There was an error signing out");
});
};

};

0 comments on commit d9ec4f7

Please sign in to comment.