Get list of user email addresses with AngularFire

别来无恙 提交于 2021-01-05 11:51:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!