firebase-authentication

Firebase database, make auth uid the default id of a document

浪尽此生 提交于 2019-12-06 14:52:37
How can I make the generated uid from auth 's createUserWithEmailAndPassword(email, pass) be the uid of document? I have this code as a signup function : $scope.signup = function (user) { auth.createUserWithEmailAndPassword(user.email, user.password) .then(ok => { // remove pass before saving delete user.password; // assigning the uid user.uid = ok.uid; // saving to userRef = ...ref().child('/accounts') userRef.push(user) .then(snap => console.log(snap)) .catch(err => console.log(err)); }) .catch(e => console.log(e.message)); } The code above does what is expected, the output is here So data

How to redirect to a specific page according to a condition in React-Router 4

橙三吉。 提交于 2019-12-06 14:48:52
How to redirect to a specific page according to a condition in "react-router": "^4.0.0" . var { HashRouter, Route, Switch} = require('react-router-dom'); var {Provider} = require('react-redux'); firebase.auth().onAuthStateChanged((user) => { if (user){ this.props.history.push('/todos/'); }else{ this.props.history.push('/'); } }); store.dispatch(actions.startAddTodos()); ReactDOM.render( <Provider store = {store}> <div> <HashRouter> <div> <div className="columns medium-6 large-4 small-centered"> <Switch> <Route path='/todos' component={TodoApp}/> <Route path='/login' component={Login}/> <Route

Firebase User re-authentication initialising error

ⅰ亾dé卋堺 提交于 2019-12-06 14:48:27
问题 When any user wants to update his/her password from app, i want to update that password of same FCM user and for that i have tried below code which define in official doc. here is the screenshot of that Here is my code func authenticateAndUpdateFCMUserPassword(strNewPassword: String) { let user = Auth.auth().currentUser var credential: AuthCredential // Prompt the user to re-provide their sign-in credentials user?.reauthenticate(with: credential) { error in if let error = error { // An error

How to build a Stream based on a Future result in Flutter?

雨燕双飞 提交于 2019-12-06 14:23:34
问题 I have a Flutter app which uses Firebase-storage and google-signin. the steps I am trying to do is so simple: 1- Sign-in using Google (Done). 2- Get Current User Id (Done). 3- Use the User Id when construct the stream for the stream builder (the problem). what I did so far is that I am using a Future to get the Current User Id, then to inject the user Id inside the Where clause .where('userId', isEqualTo: userId) and this is what I end up with: this is the part where I should create the

FirebaseAuth.getInstance() crashes with “IllegalArgumentException: Given String is empty or null”

守給你的承諾、 提交于 2019-12-06 14:12:11
I was trying to create a login system from my app, but it crashes when I open it. I managed to locate the bug to the line mFirebaseAuth = FirebaseAuth.getInstance(); which makes no sense to me. Here is the code: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Initialize Firebase Auth mFirebaseAuth = FirebaseAuth.getInstance(); mFirebaseUser = mFirebaseAuth.getCurrentUser(); if (mFirebaseUser == null) { // Not logged in, launch the Log In activity loadLogInView(); } } private void loadLogInView() { Intent intent

How can i send different users to separate view controllers using firebase and Xcode

旧城冷巷雨未停 提交于 2019-12-06 13:53:38
问题 I am fairly new to coding and have started using firebase as a back end server for an application i am creating in Xcode using swift. The app itself will have one login page but 3 separate types of users. The admin will have different permissions to the other 2 users. The code I currently have is: FIRAuth.auth()?.signIn(withEmail: username!, password: password!, completion: { (user, error) in if error == nil { let vc = self.storyboard?.instantiateViewController(withIdentifier: "AdminVC") self

Firestore security rules with spaces in path

岁酱吖の 提交于 2019-12-06 13:30:51
问题 I need to create a firestore rule for a sub collection called "Test Cases". Since firestore rules aren't written in javascript, I can't seem to get the path after match to accept a space without an error. I've tried quotes, backslashes for escape characters, and putting the whole path in quotes. I haven't found anything for this in the firestore documentation or on stack overflow. How can I allow a spaces in the path after match, in the example below, in the path including "Test Cases"?

Pushing a view controller using Swift 4 after Google Sign In

时光总嘲笑我的痴心妄想 提交于 2019-12-06 13:28:06
I'm using Firebase and Swift 4 to develop my app, but I'm having trouble pushing a new view controller after Google Sign In finishes. From what I know, I should be putting the pushViewController code in the didSignIn method, but that section is in my AppDelegate.swift file (as it implements GIDSignInDelegate, as per the Firebase documentation). func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) { // ... if let error = error { // ... return } guard let authentication = user.authentication else { return } let credential = GoogleAuthProvider.credential

How prevent username from duplicate signUp in Firebase? [duplicate]

跟風遠走 提交于 2019-12-06 11:21:52
This question already has answers here : Firebase android : make username unique (3 answers) Closed 3 years ago . I want to prevent duplicate username while signUp form what user entered. I have created email login like below, firtly createUser and then auth it setValue with user dictionary. But I stack with Firebase security settings and how to check handle this situation. REF_BASE.createUser(email, password: pwd, withValueCompletionBlock: { .. REF_BASE.authUser(email, password: pwd, withCompletionBlock: { .. REF_USERS.childByAppendingPath(uid).setValue(user) This handling always response

Create custom validation on Firebase Database Rules

♀尐吖头ヾ 提交于 2019-12-06 11:12:51
I want to create a chat application using firebase real time db, I already have my own server and my own authentication for my users and recipient. So basically what I want to do is: I want my server to able to generate room, and its room secret key, so only to people I share the secret key who can access the room, do read and write maybe the flow is like this 1. The server create a POST using REST API to this url curl -X PUT \ https://example-chat-92682.firebaseio.com/order-test.json \ -d '{ "UB8Hdazo834-4760": { "secret": "secret123" } }' So it will generate following structure - order-test