Skip to content

Commit

Permalink
feat: implement GH-login
Browse files Browse the repository at this point in the history
  • Loading branch information
tensegrity666 committed Sep 10, 2020
1 parent 43a5565 commit f5f89e2
Show file tree
Hide file tree
Showing 8 changed files with 18,693 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
REACT_APP_API_KEY=AIzaSyDWfjbWSDjJ9Nnjjy8dD7Czop8YBMeie3E
REACT_APP_AUTH_DOMAIN=x-check-awesome.firebaseapp.com
REACT_APP_DATABASE_URL=https://x-check-awesome.firebaseio.com
REACT_APP_PROJECT_ID=x-check-awesome
REACT_APP_STORAGE_BUCKET=x-check-awesome.appspot.com
REACT_APP_MESSAGING_SENDER_ID=330795781190
REACT_APP_APP_ID=1:330795781190:web:75daed787a2cdbd65b4e47
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# need to uncomment it in next PR
#.env

# dependencies
/node_modules
/.pnp
Expand Down
18,640 changes: 18,640 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"private": true,
"dependencies": {
"@ant-design/icons": "^4.2.2",
"@firebase/app": "^0.6.10",
"@firebase/auth": "^0.14.9",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.0.2",
"@testing-library/user-event": "^12.1.3",
Expand Down
3 changes: 3 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<!-- <script src="/__/firebase/7.19.1/firebase-app.js"></script>
<script src="/__/firebase/init.js"></script> -->
</body>
</html>
2 changes: 1 addition & 1 deletion src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'antd/dist/antd.css';
import store from '../redux/store';

const App = () => {
const isAuthenticated = true;
const isAuthenticated = false;
const routes = useRoutes(isAuthenticated);

return (
Expand Down
5 changes: 3 additions & 2 deletions src/components/login/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import { Card, Button } from 'antd';
import { GithubOutlined } from '@ant-design/icons';
import githubAuth from '../../services/firebase';

import RSLogo from './assets/logo-rs-school.svg';
import GitHubIcon from './assets/ic-github-base64.json';
import styles from './index.module.css';

const { Meta } = Card;

const Login = () => {
const { Meta } = Card;
return (
<main>
<div className={styles.form}>
Expand All @@ -25,6 +25,7 @@ const Login = () => {
}
actions={[
<Button
onClick={githubAuth}
key="github"
type="primary"
size="large"
Expand Down
34 changes: 34 additions & 0 deletions src/services/firebase/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { firebase } from '@firebase/app';
import '@firebase/auth';

const firebaseConfig = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_APP_ID,
};

firebase.default.initializeApp(firebaseConfig);
const provider = new firebase.auth.GithubAuthProvider();

const githubAuth = () => {
firebase
.auth()
.signInWithPopup(provider)
.then((result) => {
const { user } = result;
// eslint-disable-next-line no-console
console.log(user);
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// eslint-disable-next-line no-console
console.log(errorCode, errorMessage);
});
};

export default githubAuth;

1 comment on commit f5f89e2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Netlify deployed x-check-app as production

https://x-check-app.netlify.app

Please sign in to comment.