Firebase - Prevent user authentication -
i need prevent user authentication if email isn't found in allowedusers
. doesn't affect app, since actions performed on users
list, nice if authentication doesn't happen.
loginwithgoogle() { const userdetails = this.afauth.auth.signinwithpopup(new firebase.auth.googleauthprovider()) .then(user => { console.log(user.user.uid); const queryobservable = this.db.list('/allowedusers', { query: { orderbychild: 'email', equalto: user.user.email, } }).subscribe(data => { if (data.length > 0) { const userobj = { admin: false, ... email: data[0].email, name: data[0].name, verified: false, }; this.adduser(userobj, user.user.uid); } }); }); return userdetails; }
there no way prevent user authenticating firebase authentication. when authenticate "i x yz" , prove it.
what can prevent have access database. example allow white-listed users read-access database:
{ "rules": { ".read": "root.child('allowedusers').child(auth.uid).exists()" } }
also see:
- how disable signup in firebase 3.x
- firebase authentication state change not fire when user disabled or deleted (inverted version of whitelist)
Comments
Post a Comment