我的网络应用程序使用Firebase JS + AngularFire显示应用程序中用户的报告(仅对管理员可见)。如何使用AngularFire检索用户的电子邮件地址?
查看AngularFire API参考,我在$firebaseAuth
部分没有看到可用的方法:https://github.com/firebase/angularfire/blob/master/docs/reference.md
答案 0 :(得分:1)
除非您前往firebase控制台并进行手动检查,否则您无法轻松访问该内容。 在firebase中,建议您在数据库中创建另一个名为Users的节点,用于存储用户信息。这将帮助您在需要时轻松获取信息。
检查我的示例代码,了解如何创建新用户。
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
}
});
}