问题
My web application uses Firebase JS + AngularFire to display a report of users in the application (visible only to admins). How can I retrieve a user's email address using AngularFire?
Looking at the AngularFire API Reference, I don't see an available method for doing this in the $firebaseAuth
section: https://github.com/firebase/angularfire/blob/master/docs/reference.md
回答1:
You can't easily access that unless you go to the firebase console and do a manual check. In firebase it is advised that you create another node called Users in your database to be used in storing Users info. This will help you to easily get the info when you need them.
Check my sample code on how to create a new user.
signUp() {
if (this.signupForm.valid) {
//grab login form values
let email = this.signupForm.get('email').value;
let password = this.signupForm.get('password').value;
let confirmpassword = this.signupForm.get('confirmpassword').value;
let petname = this.signupForm.get('petname').value;
let full_name = this.signupForm.get('full_name').value;
let address = this.signupForm.get('address').value;
let phone = this.signupForm.get('phone').value;
let default_role = this.signupForm.get('default_role').value;
//signup new user
this.security.signup(email, password).then((response) => {
//userid
let userid = response.auth.uid;
//create a new user using form values
let newUser: User = {
full_name: full_name,
password: password,
petname: petname,
email: email,
phone: phone,
default_role: default_role,
usercode: newusercode
};
//add new user to database table section
this.af.database.object("/Users/" + userid).set(newUser).then(() => {
//prepare userinfo for cache
let userInfo = {
uid: userid,
petname: petname,
default_role: default_role
}
});
}
来源:https://stackoverflow.com/questions/44959788/get-list-of-user-email-addresses-with-angularfire