gpt4 book ai didi

javascript - 如何修改此 PolymerFire/Firebase 教程以使用电子邮件/密码登录而不是谷歌帐户?

转载 作者:行者123 更新时间:2023-12-03 01:07:01 25 4
gpt4 key购买 nike

我想修改此 Notes 应用程序以使用电子邮件/密码登录,而不是使用 Google 帐户:

Build a Progressive Web App with Firebase, Polymerfire and Polymer Components

<firebase-auth
id="auth"
app-name="notes"
provider="google"
signed-in="{{signedIn}}"
user="{{user}}">
</firebase-auth>

<script>
Polymer({is: 'note-app', behaviors: [Polymer.NoteAppBehavior],
signIn: function() {this.$.auth.signInWithPopup();}});
</script>

我在这里确定了该方法:FirebaseExtended/polymerfire/firebase-auth.html

我需要 signInWithEmailAndPassword(),而不是 signInWithPopup():

    /**
* Authenticates a Firebase client using an email / password combination.
*
* @param {!String} email Email address corresponding to the user account.
* @param {!String} password Password corresponding to the user account.
* @return {Promise} Promise that handles success and failure.
*/
signInWithEmailAndPassword: function(email, password) {
return this._handleSignIn(this.auth.signInWithEmailAndPassword(email, password));
},

最佳答案

我正在使用这个:

<firebase-auth id="auth" user="{{user}}" on-error="_loginError"></firebase-auth>
<paper-dialog id="authDialog" modal with-backdrop>
<paper-input label="Email" value="{{signinEmail}}"></paper-input>
<paper-input label="Password" value="{{signinPassword}}" type="password"></paper-input>
<div class="buttons">
<paper-button on-click="_signIn" raised>Sign in</paper-button>
</div>
</paper-dialog>

并通过以下方式访问身份验证:

  _signIn: function() {
this.$.auth.signInWithEmailAndPassword(this.signinEmail, this.signinPassword)
.then(function(response) {
console.log(response);
}.bind(this), function(error) {
this.$.toast.show({text: '' + error});
}.bind(this))
.catch(function(error) {
this.$.toast.show({text: '' + error});
}.bind(this));
},

但首先您需要从 Firebase 控制台启用电子邮件密码身份验证方法,以便能够使用电子邮件密码身份验证。

关于javascript - 如何修改此 PolymerFire/Firebase 教程以使用电子邮件/密码登录而不是谷歌帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52351767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com