Javascript ionic,firebase:如何从firebase身份验证获取所有用户电子邮件
我正在尝试获取firebase身份验证存储区中所有用户的用户电子邮件,我需要这些信息,以便允许用户在系统内相互发送消息。我对爱奥尼亚不是很有经验,所以如果这是个愚蠢的问题,请原谅我。 我不需要登录的用户的电子邮件,我已经有权访问它,但我有困难访问所有他们 登录代码,不确定是否确实需要Javascript ionic,firebase:如何从firebase身份验证获取所有用户电子邮件,javascript,firebase,ionic-framework,firebase-authentication,ionic4,Javascript,Firebase,Ionic Framework,Firebase Authentication,Ionic4,我正在尝试获取firebase身份验证存储区中所有用户的用户电子邮件,我需要这些信息,以便允许用户在系统内相互发送消息。我对爱奥尼亚不是很有经验,所以如果这是个愚蠢的问题,请原谅我。 我不需要登录的用户的电子邮件,我已经有权访问它,但我有困难访问所有他们 登录代码,不确定是否确实需要 // login.page.ts import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Valida
// login.page.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { NavController } from '@ionic/angular';
import { AuthenticationService } from '../services/authentication.service';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
validations_form: FormGroup;
errorMessage: string = '';
constructor(
private navCtrl: NavController,
private authService: AuthenticationService,
private formBuilder: FormBuilder
) { }
ngOnInit() {
this.validations_form = this.formBuilder.group({
email: new FormControl('', Validators.compose([
Validators.required,
Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$')
])),
password: new FormControl('', Validators.compose([
Validators.minLength(5),
Validators.required
])),
});
}
validation_messages = {
'email': [
{ type: 'required', message: 'Email is required.' },
{ type: 'pattern', message: 'Please enter a valid email.' }
],
'password': [
{ type: 'required', message: 'Password is required.' },
{ type: 'minlength', message: 'Password must be at least 5 characters long.' }
]
};
loginUser(value) {
this.authService.loginUser(value)
.then(res => {
console.log(res);
this.errorMessage = "";
this.navCtrl.navigateForward('/welcome');
}, err => {
this.errorMessage = err.message;
})
}
goToRegisterPage() {
this.navCtrl.navigateForward('/register');
}
}
注册码
// register.page.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { AuthenticationService } from '../services/authentication.service';
import { NavController } from '@ionic/angular';
@Component({
selector: 'app-register',
templateUrl: './register.page.html',
styleUrls: ['./register.page.scss'],
})
export class RegisterPage implements OnInit {
validations_form: FormGroup;
errorMessage: string = '';
successMessage: string = '';
validation_messages = {
'email': [
{ type: 'required', message: 'Email is required.' },
{ type: 'pattern', message: 'Enter a valid email.' }
],
'password': [
{ type: 'required', message: 'Password is required.' },
{ type: 'minlength', message: 'Password must be at least 5 characters long.' }
]
};
constructor(
private navCtrl: NavController,
private authService: AuthenticationService,
private formBuilder: FormBuilder
) { }
ngOnInit() {
this.validations_form = this.formBuilder.group({
email: new FormControl('', Validators.compose([
Validators.required,
Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$')
])),
password: new FormControl('', Validators.compose([
Validators.minLength(5),
Validators.required
])),
});
}
tryRegister(value) {
this.authService.registerUser(value)
.then(res => {
console.log(res);
this.errorMessage = "";
this.successMessage = "Your account has been created. Please log in.";
}, err => {
console.log(err);
this.errorMessage = err.message;
this.successMessage = "";
})
}
goLoginPage() {
this.navCtrl.navigateForward('/login');
}
}
我想得到的是
电子邮件1
电子邮件2
电邮3
email4/ion选择选项>
//可能会使用*ngFor来完成此操作。
客户端Firebase身份验证SDK无法获取系统中所有用户的电子邮件地址,因为这将存在潜在的安全风险 如果你的应用程序需要此功能,你必须自己构建。两个最常见的选项是:
<ion-select>
<ion-select-option value="email1">email1</ion-select-option>
<ion-select-option value="email2">email2</ion-select-option>
<ion-select-option value="email3">email3</ion-select-option>
<ion-select-option value="email4">email4/ion-select-option>
</ion-select> //probably will use *ngFor to do this.