允许用户拥有唯一权限

时间:2018-01-01 20:55:33

标签: javascript firebase ionic-framework firebase-authentication

我希望用户通过其用户ID保存到firebase。

这是我的注册码。

我不知道这里是否缺少允许用户拥有唯一访问权限的内容?

export class SignupPage {
  signupData = {
    email: '',
    password: '',
    passwordRetyped: ''
  };

  constructor(private navCtrl: NavController, private navParams: NavParams, private alertCtrl: AlertController,
    private afAuth: AngularFireAuth) {
    this.signupData.email = this.navParams.get('email');
  }

  signup() {
    if(this.signupData.password !== this.signupData.passwordRetyped) {
      let alert = this.alertCtrl.create({
        title: 'Error',
        message: 'Your password and your re-entered password does not match each other.',
    buttons: ['OK']
      });
      alert.present();
      return;
    }
    // Firebase Signup Code
      this.afAuth.auth.createUserWithEmailAndPassword(this.signupData.email, this.signupData.password)
    .then(auth => {
      // Could do something with the Auth-Response
      console.log(auth);
    })
    .catch(err => {
      // Handle error
      let alert = this.alertCtrl.create({
        title: 'Error',
        message: err.message,
        buttons: ['OK']
      });
      alert.present();
    });
  }
}

0 个答案:

没有答案