-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove obsolete files * made Login as configurable component * externalize auth * moderator
- Loading branch information
1 parent
86d2e4f
commit 18cdc12
Showing
12 changed files
with
93 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,31 @@ | ||
import User from "../types/User"; | ||
import firebaseApp from "./firebaseInit"; | ||
import dbFirebase from "./dbFirebase"; | ||
|
||
let currentUser; | ||
|
||
/** | ||
* When the user login call fn | ||
* @param fn | ||
*/ | ||
const onAuthStateChanged = async (fn) => { | ||
const firebaseStatusChange = async (user) => { | ||
currentUser = user; | ||
if (currentUser) { | ||
const fbUser = await dbFirebase.getUser(user.uid); | ||
|
||
currentUser = new User(currentUser.uid, currentUser.displayName, fbUser.isModerator, currentUser.email, currentUser.emailVerified, currentUser.isAnonymous, currentUser.phoneNumber, currentUser.photoURL); | ||
} | ||
fn(currentUser); | ||
}; | ||
|
||
return firebaseApp.auth().onAuthStateChanged(firebaseStatusChange); | ||
}; | ||
|
||
const signOut = () => { | ||
firebaseApp.auth().signOut(); | ||
}; | ||
|
||
const getCurrentUser = () => currentUser; | ||
|
||
export default { onAuthStateChanged, signOut, getCurrentUser } |
This file contains 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 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 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 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 @@ | ||
class User { | ||
constructor(id, displayName, isModerator, email, emailVerified, isAnonymous, phoneNumber, photoURL) { | ||
this.id = id; | ||
this.displayName = displayName; | ||
this.isModerator = isModerator; | ||
this.email = email; | ||
this.emailVerified = emailVerified; | ||
this.isAnonymous = isAnonymous; | ||
this.phoneNumber = phoneNumber; | ||
this.photoURL = photoURL; | ||
} | ||
} | ||
|
||
export default User; |