如何修改此 PolymerFire/Firebase 教程以使用 email/password 登录名而不是 google 帐户?
How to modify this PolymerFire/Firebase tutorial to work with email/password login instead of google account?
我想修改此 Notes 应用程序以使用 email/password 登录而不是使用 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
而不是 signInWithPopup()
,我需要 signInWithEmailAndPassword()
:
/**
* 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 控制台启用电子邮件密码验证方法才能使用电子邮件密码验证。
我想修改此 Notes 应用程序以使用 email/password 登录而不是使用 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
而不是 signInWithPopup()
,我需要 signInWithEmailAndPassword()
:
/**
* 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 控制台启用电子邮件密码验证方法才能使用电子邮件密码验证。