basic setup
This commit is contained in:
@@ -26,16 +26,12 @@ class AuthStore {
|
||||
## Functions
|
||||
##
|
||||
## load
|
||||
## getUserInfo
|
||||
## verifyPhone
|
||||
## signIn
|
||||
## signOut
|
||||
/*#######################################################*/
|
||||
load() {
|
||||
//Load all auth related things
|
||||
|
||||
console.info("Loading authStore");
|
||||
this.stores.rootStore.isLoaded.app = false;
|
||||
|
||||
firebase.auth().onAuthStateChanged((user) => {
|
||||
if (user) {
|
||||
//Logged in
|
||||
@@ -63,47 +59,6 @@ class AuthStore {
|
||||
}
|
||||
|
||||
|
||||
getUserInfo(userId) {
|
||||
//Returns all user info from firestore.
|
||||
//Param: userId
|
||||
//Returns a promise
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var docRef = db.collection("users").doc(userId);
|
||||
return docRef.get().then((doc) => {
|
||||
if (doc.exists) {
|
||||
resolve(doc.data());
|
||||
} else {
|
||||
// doc.data() will be undefined in this case
|
||||
alertify.delay(0).error("Base Web doesn't support signing up yet. Please install the mobile app to sign up! Refresh Base Web after!");
|
||||
console.error("User with id " + userId + " not found in user db!");
|
||||
reject()
|
||||
}
|
||||
}).catch(function(error) {
|
||||
console.error("Error getting document:", error);
|
||||
reject()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createSignInRecaptcha(phoneNumber) {
|
||||
firebase.auth().useDeviceLanguage();
|
||||
|
||||
window.recaptchaVerifier = new firebase_orig.auth.RecaptchaVerifier('sign-in-button', {
|
||||
'size': 'invisible',
|
||||
'callback': (response) => {
|
||||
// reCAPTCHA solved, allow signInWithPhoneNumber.
|
||||
this.signIn();
|
||||
}
|
||||
});
|
||||
|
||||
window.recaptchaVerifier.render().then(function(widgetId) {
|
||||
window.recaptchaWidgetId = widgetId;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
signIn(){
|
||||
//Verify phone number and then sign in
|
||||
|
||||
|
@@ -35,10 +35,10 @@ class RootStore {
|
||||
## Functions
|
||||
##
|
||||
## loadApp
|
||||
## promiseAll
|
||||
/*#######################################################*/
|
||||
loadApp() {
|
||||
console.log("Your browser: " + browser());
|
||||
const result = browser();
|
||||
console.log("Your browser: " , result);
|
||||
|
||||
if(navigator.cookiesEnabled) {
|
||||
alertify.delay(0).error("Please activate cookies in your browser! Refresh after");
|
||||
|
Reference in New Issue
Block a user