diff --git a/client/src/App.js b/client/src/App.js index 61df46b..9c7a779 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -34,141 +34,142 @@ import logo from './images/edue_logo.png'; import './App.css'; const styles = { - card: { - minWidth: 275, - marginTop: 50, - borderSize: 5, - borderStyle: 'solid', - borderWidth: 3, - borderColor: 'var(--main-bg-color)', - }, + card: { + minWidth: 275, + marginTop: 50, + borderSize: 5, + borderStyle: 'solid', + borderWidth: 3, + borderColor: 'var(--main-bg-color)', + }, }; class App extends Component { - constructor() { - super(); - this.state = { - user: null, - }; + constructor() { + super(); + this.state = { + user: null, + }; - this.login = this.login.bind(this); - this.logout = this.logout.bind(this); - } + this.login = this.login.bind(this); + this.logout = this.logout.bind(this); + } - componentDidMount() { - // When the user signs in, this checks the Firebase database to see - // if they were already previously authenticated. - // If they were, we set their user details back into the state. - auth.onAuthStateChanged((user) => { - if (user) { - this.setState({ user }); - } - }); - } + componentDidMount() { + // When the user signs in, this checks the Firebase database to see + // if they were already previously authenticated. + // If they were, we set their user details back into the state. + auth.onAuthStateChanged((user) => { + if (user) { + this.setState({ user }); + } + }); + } - // Handles authentication with firebase. - // Here we call the signInWithPopup method from the auth module, - // and pass in our provider (remember this refers to the Google Auth Provider). - // Now, when you click the 'login' button, it will trigger a popup - // that gives us the option to sign in with a Google account - // signInWithPopup has a promise API that allows us to call - // .then on it and pass in a callback. - // This callback will be provided with a result object that contains, - // among other things, a property called .user that has all the - // information about the user who has just successfully signed in - // including their name and user photo. We then store this inside of the state using setState. - login() { - auth.signInWithPopup(provider) - .then((result) => { - // console.log(result); - const user = result.user; - this.setState({ - user, - }); - }); - } + // Handles authentication with firebase. + // Here we call the signInWithPopup method from the auth module, + // and pass in our provider (remember this refers to the Google Auth Provider). + // Now, when you click the 'login' button, it will trigger a popup + // that gives us the option to sign in with a Google account + // signInWithPopup has a promise API that allows us to call + // .then on it and pass in a callback. + // This callback will be provided with a result object that contains, + // among other things, a property called .user that has all the + // information about the user who has just successfully signed in + // including their name and user photo. We then store this inside of the state using setState. + login() { + auth.signInWithPopup(provider) + .then((result) => { + // console.log(result); + const user = result.user; + this.setState({ + user, + }); + }); + } - // We call the signOut method on auth, - // and then using the Promise API - // we remove the user from our application's state. - // With this.state.user now equal to null, - // the user will see the Log In button instead of the Log Out button. - logout() { - auth.signOut() - .then(() => { - this.setState({ - user: null, - }); - }); - } + // We call the signOut method on auth, + // and then using the Promise API + // we remove the user from our application's state. + // With this.state.user now equal to null, + // the user will see the Log In button instead of the Log Out button. + logout() { + auth.signOut() + .then(() => { + this.setState({ + user: null, + }); + }); + } - render() { - const { user } = this.state; - const { classes } = this.props; - // console.log(user); - return (
Login with Google to continue to site.
-