-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/core/add firebase #36
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
Open
rishiosaur
wants to merge
22
commits into
master
Choose a base branch
from
feature/core/add-firebase
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
391e19c
add firebaserc
rishiosaur 9cf579a
add firebase config
rishiosaur 5b65ab4
add firestore indexes
rishiosaur b38ae9f
basic firestore rules
rishiosaur 6ec8dd3
basic storage rules
rishiosaur 60a0510
add theme
rishiosaur 462a72d
update naming
rishiosaur 6e7678d
navLayout
rishiosaur 994624a
update deps
rishiosaur aa77275
add firebase
rishiosaur ebb8bfa
add .env to gitignore
rishiosaur 39ab57e
add firebaseconfig
rishiosaur 8be5fd8
initialize store modules
rishiosaur b6b85ed
add decorators
rishiosaur 7c82721
auth
rishiosaur 42051ab
update imports
rishiosaur 2a30664
update imports
rishiosaur d5ed5bc
delete all stores
rishiosaur 02675f1
move to data
rishiosaur 78ba2e2
update contexts
rishiosaur 6b3ae48
authstore
rishiosaur 166937b
moving around channel stores
rishiosaur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "projects": { | ||
| "default": "rapid-ce500" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "firestore": { | ||
| "rules": "firestore.rules", | ||
| "indexes": "firestore.indexes.json" | ||
| }, | ||
| "hosting": { | ||
| "public": "build", | ||
| "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], | ||
| "rewrites": [ | ||
| { | ||
| "source": "**", | ||
| "destination": "/index.html" | ||
| } | ||
| ] | ||
| }, | ||
| "storage": { | ||
| "rules": "storage.rules" | ||
| }, | ||
| "emulators": { | ||
| "firestore": { | ||
| "port": 69420 | ||
| }, | ||
| "hosting": { | ||
| "port": 42069 | ||
| }, | ||
| "ui": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "indexes": [], | ||
| "fieldOverrides": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| rules_version = '2'; | ||
| service cloud.firestore { | ||
| match /databases/{database}/documents { | ||
|
|
||
| // This rule allows anyone with your database reference to view, edit, | ||
| // and delete all data in your Firestore database. It is useful for getting | ||
| // started, but it is configured to expire after 30 days because it | ||
| // leaves your app open to attackers. At that time, all client | ||
| // requests to your Firestore database will be denied. | ||
| // | ||
| // Make sure to write security rules for your app before that time, or else | ||
| // all client requests to your Firestore database will be denied until you Update | ||
| // your rules | ||
| match /{document=**} { | ||
| allow read, write: if request.time < timestamp.date(2020, 8, 29); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { theme as DefaultTheme } from '@chakra-ui/core' | ||
|
|
||
| const theme = { | ||
| ...DefaultTheme, | ||
| } | ||
|
|
||
| export default theme |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { auth } from 'firebase' | ||
| import { computed, observable } from 'mobx' | ||
| import React from 'react' | ||
|
|
||
| const defaultSucc = (user: any) => { | ||
| console.log(`Successfully signed in! \n\n ${JSON.stringify(user, null, 2)}`) | ||
| } | ||
|
|
||
| const defaultErr = (err: any) => { | ||
| console.error( | ||
| `Could not sign in through google. \n\n ${JSON.stringify(err, null, 2)}` | ||
| ) | ||
| } | ||
|
|
||
| class IAuthStore { | ||
| @observable user: any = null | ||
| @observable authPending = true | ||
|
|
||
| listenToAuth: any | ||
|
|
||
| constructor() { | ||
| this.listenToAuth = auth().onAuthStateChanged( | ||
| (user) => { | ||
| this.user = user | ||
|
|
||
| this.authPending = false | ||
| }, | ||
| (err) => { | ||
| console.error(err) | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| public async doSignInWithGoogle() { | ||
| const provider = new auth.GoogleAuthProvider() | ||
| await auth().signInWithPopup(provider).then(defaultSucc, defaultErr) | ||
| } | ||
|
|
||
| public async doSignInWithEmail(e: string, p: string) { | ||
| await auth().signInWithEmailAndPassword(e, p).then(defaultSucc, defaultErr) | ||
| } | ||
|
|
||
| @computed | ||
| public get isAuthed() { | ||
| return !!this.user | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There supposed to be two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @safinsingh that ensures the result is a boolean since |
||
| } | ||
| } | ||
|
|
||
| export const AuthStore = new IAuthStore() | ||
|
|
||
| export const AuthContext = React.createContext(AuthStore) | ||
|
|
||
| export const AuthProvider: React.FunctionComponent<React.ReactNode> = ({ | ||
| children, | ||
| }) => { | ||
| return ( | ||
| <AuthContext.Provider value={AuthStore}>{children}</AuthContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export default AuthStore | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { auth } from 'firebase' | ||
| import { computed, observable } from 'mobx' | ||
| import React from 'react' | ||
|
|
||
| const defaultSucc = (user: any) => { | ||
| console.log(`Successfully signed in! \n\n ${JSON.stringify(user, null, 2)}`) | ||
| } | ||
|
|
||
| const defaultErr = (err: any) => { | ||
| console.error( | ||
| `Could not sign in through google. \n\n ${JSON.stringify(err, null, 2)}` | ||
| ) | ||
| } | ||
|
|
||
| class IAuthStore { | ||
| @observable user: any = null | ||
| @observable authPending = true | ||
|
|
||
| listenToAuth: any | ||
|
|
||
| constructor() { | ||
| this.listenToAuth = auth().onAuthStateChanged( | ||
| (user) => { | ||
| this.user = user | ||
|
|
||
| this.authPending = false | ||
| }, | ||
| (err) => { | ||
| console.error(err) | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| public async doSignInWithGoogle() { | ||
| const provider = new auth.GoogleAuthProvider() | ||
| await auth().signInWithPopup(provider).then(defaultSucc, defaultErr) | ||
| } | ||
|
|
||
| public async doSignInWithEmail(e: string, p: string) { | ||
| await auth().signInWithEmailAndPassword(e, p).then(defaultSucc, defaultErr) | ||
| } | ||
|
|
||
| @computed | ||
| public get isAuthed() { | ||
| return !!this.user | ||
| } | ||
| } | ||
|
|
||
| export const AuthStore = new IAuthStore() | ||
|
|
||
| export const AuthContext = React.createContext(AuthStore) | ||
|
|
||
| export const AuthProvider: React.FunctionComponent<React.ReactNode> = ({ | ||
| children, | ||
| }) => { | ||
| return ( | ||
| <AuthContext.Provider value={AuthStore}>{children}</AuthContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export default AuthStore |
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default as AuthStore } from './Auth' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { initializeApp } from 'firebase' | ||
|
|
||
| const firebaseConfig = { | ||
| apiKey: process.env.REACT_APP_FapiKey, | ||
| authDomain: process.env.REACT_APP_FauthDomain, | ||
| databaseURL: process.env.REACT_APP_FdatabaseURL, | ||
| projectId: process.env.REACT_APP_FprojectId, | ||
| storageBucket: process.env.REACT_APP_FstorageBucket, | ||
| messagingSenderId: process.env.REACT_APP_FmessagingSenderId, | ||
| appId: process.env.REACT_APP_FappId, | ||
| measurementId: process.env.REACT_APP_FmeasurementId, | ||
| } | ||
|
|
||
| initializeApp(firebaseConfig) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| import React from 'react' | ||
|
|
||
| import DisplayNavAndPage from '../components/organisms/DisplayNavAndPage' | ||
| import NavLayout from '../components/organisms/DisplayNavAndPage' | ||
|
|
||
| export default function Chat(): JSX.Element { | ||
| return ( | ||
| <DisplayNavAndPage> | ||
| <NavLayout> | ||
| <h1>Messages</h1> | ||
| </DisplayNavAndPage> | ||
| </NavLayout> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import React from 'react' | ||
|
|
||
| import DisplayNavAndPage from '../components/organisms/DisplayNavAndPage' | ||
| import NavLayout from '../components/organisms/DisplayNavAndPage' | ||
| import FriendList from '../components/organisms/FriendList' | ||
|
|
||
| export default function UsersPage() { | ||
| return ( | ||
| <DisplayNavAndPage> | ||
| <NavLayout> | ||
| <FriendList /> | ||
| </DisplayNavAndPage> | ||
| </NavLayout> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| service firebase.storage { | ||
| match /b/{bucket}/o { | ||
| match /{allPaths=**} { | ||
| allow read, write: if request.auth!=null; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌