Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ionic,firebase:如何从firebase身份验证获取所有用户电子邮件_Javascript_Firebase_Ionic Framework_Firebase Authentication_Ionic4 - Fatal编程技术网

Javascript ionic,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

我正在尝试获取firebase身份验证存储区中所有用户的用户电子邮件,我需要这些信息,以便允许用户在系统内相互发送消息。我对爱奥尼亚不是很有经验,所以如果这是个愚蠢的问题,请原谅我。 我不需要登录的用户的电子邮件,我已经有权访问它,但我有困难访问所有他们

登录代码,不确定是否确实需要

// 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无法获取系统中所有用户的电子邮件地址,因为这将存在潜在的安全风险

    如果你的应用程序需要此功能,你必须自己构建。两个最常见的选项是:

  • 实现使用Firebase Admin SDK的自定义服务器端API,Firebase Admin SDK具有此类功能
  • 将必要的用户数据存储在数据库中,如Firebase的实时数据库或Cloud Firestore,并让客户机在那里访问
  • 在这两种情况下,您的应用程序都可以控制用户的哪些数据被公开,从而解决安全问题

    另见:


    客户端Firebase身份验证SDK无法获取系统中所有用户的电子邮件地址,因为这可能会带来安全风险

    如果你的应用程序需要此功能,你必须自己构建。两个最常见的选项是:

  • 实现使用Firebase Admin SDK的自定义服务器端API,Firebase Admin SDK具有此类功能
  • 将必要的用户数据存储在数据库中,如Firebase的实时数据库或Cloud Firestore,并让客户机在那里访问
  • 在这两种情况下,您的应用程序都可以控制用户的哪些数据被公开,从而解决安全问题

    另见:


    非常感谢,我花了很长时间查找此信息,而我能找到的唯一信息是获取当前用户的详细信息,那么是否有一种方法可以在用户登录时将其电子邮件存储在我的cloud firebase中,或者不是这样?我还担心这是否可能,如果它会产生重复的结果,并且可能需要大量的方法调用。您所描述的是我上面提到的第二个选项,这是我在这个用例中看到的最常见的方法。您可以防止重复结果,例如,通过将用户的UID作为密钥存储用户。我建议阅读我提供的一些(更深入的)链接,因为已经有很多关于这方面的信息。顺便说一句:如果我的答案有用,请单击向上投票按钮(▲) 如果它回答了您的问题,请单击复选标记(✓) 接受它。这样别人就会知道你已经(足够)了帮助。也非常感谢,我花了很长时间寻找这些信息,我能找到的唯一信息是获取当前用户的详细信息,所以有没有一种方法,每当用户登录时,我都会将他的电子邮件存储在我的cloud firebase中,或者不是这样?我还担心这是否可能会产生重复的结果,并且可能需要大量的方法调用。您所描述的是我上面提到的第二个选项,这是我在本用例中看到的最常见的方法。您可以防止重复结果,例如通过将用户的UID作为密钥存储。我建议阅读一些(更深入的)我提供的链接,因为已经有很多关于这方面的信息。顺便说一句:如果我的答案有用,请单击向上投票按钮(▲) 如果它回答了您的问题,请单击复选标记(✓) 接受它。这样别人就会知道你已经得到了(足够的)帮助。也请参见
    <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.