diff --git a/firebase-auth.html b/firebase-auth.html
index 3eb8d25..a4b1632 100644
--- a/firebase-auth.html
+++ b/firebase-auth.html
@@ -18,11 +18,17 @@
Example Usage:
```html
-
+
-
+
+
```
@@ -35,8 +41,8 @@
```javascript
this.$.auth.signInWithPopup()
- .then(function(response) {// optionally handle a successful login})
- .catch(function(error) {// unsuccessful authentication response here});
+ .then(function(response) {// optionally handle a successful login})
+ .catch(function(error) {// unsuccessful authentication response here});
```
This popup sign-in will then attempt to sign in using Google as an OAuth
@@ -130,7 +136,45 @@
notify: true,
readOnly: true,
reflectToAttribute: true
- }
+ },
+
+ /**
+ * Email address corresponding to the user account. This property
+ * can remain undefined when specifying a email in the email function calls
+ * (i.e. `signInWithEmailAndPassword`, `createUserWithEmailAndPassword` and `sendPasswordResetEmail`).
+ */
+ email: {
+ type: String,
+ notify: true
+ },
+
+ /**
+ * Password corresponding to the user account. This property
+ * can remain undefined when specifying a password in the email function calls
+ * (i.e. `signInWithEmailAndPassword` and `createUserWithEmailAndPassword`).
+ */
+ password: {
+ type: String,
+ notify: true
+ },
+
+ /**
+ * JSON Web Token. This property can remain undefined when
+ * specifying a token in the `signInWithCustomToken` function.
+ */
+ token: {
+ type: String,
+ notify: true
+ },
+
+ /**
+ * OAuth id_token. This property can remain undefined when
+ * specifying a credential in the `signInWithCredential` function.
+ */
+ credential: {
+ type: String,
+ notify: true
+ },
},
@@ -143,31 +187,36 @@
if (!this.auth) {
return Promise.reject('No app configured for firebase-auth!');
}
-
return this._handleSignIn(this.auth.signInAnonymously());
},
/**
* Authenticates a Firebase client using a custom JSON Web Token.
*
+ * @param {?String} token JSON Web Token. If not specified,
+ * the element's `token` property value will be used.
* @return {Promise} Promise that handles success and failure.
*/
signInWithCustomToken: function(token) {
if (!this.auth) {
return Promise.reject('No app configured for firebase-auth!');
}
+ token = token || this.token;
return this._handleSignIn(this.auth.signInWithCustomToken(token));
},
/**
* Authenticates a Firebase client using an oauth id_token.
*
+ * @param {?String} credential OAuth id_token. If not specified,
+ * the element's `credential` property value will be used.
* @return {Promise} Promise that handles success and failure.
*/
signInWithCredential: function(credential) {
if (!this.auth) {
return Promise.reject('No app configured for firebase-auth!');
}
+ credential = credential || this.credential;
return this._handleSignIn(this.auth.signInWithCredential(credential));
},
@@ -203,32 +252,51 @@
/**
* 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.
+ * @param {?String} email Email address corresponding to the user account.
+ * If not specified, the element's `email` property value will be used.
+ * @param {?String} password Password corresponding to the user account.
+ * If not specified, the element's `password` property value will be used.
* @return {Promise} Promise that handles success and failure.
*/
signInWithEmailAndPassword: function(email, password) {
+ if (!this.auth) {
+ return Promise.reject('No app configured for firebase-auth!');
+ }
+ email = email || this.email;
+ password = password || this.password;
return this._handleSignIn(this.auth.signInWithEmailAndPassword(email, password));
},
/**
* Creates a new user account using an email / password combination.
*
- * @param {!String} email Email address corresponding to the user account.
- * @param {!String} password Password corresponding to the user account.
+ * @param {?String} email Email address corresponding to the user account.
+ * If not specified, the element's `email` property value will be used.
+ * @param {?String} password Password corresponding to the user account.
+ * If not specified, the element's `password` property value will be used.
* @return {Promise} Promise that handles success and failure.
*/
createUserWithEmailAndPassword: function(email, password) {
+ if (!this.auth) {
+ return Promise.reject('No app configured for firebase-auth!');
+ }
+ email = email || this.email;
+ password = password || this.password;
return this._handleSignIn(this.auth.createUserWithEmailAndPassword(email, password));
},
/**
* Sends a password reset email to the given email address.
*
- * @param {!String} email Email address corresponding to the user account.
+ * @param {?String} email Email address corresponding to the user account.
+ * If not specified, the element's `email` property value will be used.
* @return {Promise} Promise that handles success and failure.
*/
sendPasswordResetEmail: function(email) {
+ if (!this.auth) {
+ return Promise.reject('No app configured for firebase-auth!');
+ }
+ email = email || this.email;
return this._handleSignIn(this.auth.sendPasswordResetEmail(email));
},
@@ -241,19 +309,17 @@
if (!this.auth) {
return Promise.reject('No app configured for auth!');
}
-
return this.auth.signOut();
},
_attemptProviderSignIn: function(provider, method) {
- provider = provider || this._providerFromName(this.provider);
- if (!provider) {
- return Promise.reject('Must supply a provider for popup sign in.');
- }
if (!this.auth) {
return Promise.reject('No app configured for firebase-auth!');
}
-
+ provider = provider || this._providerFromName(this.provider);
+ if (!provider) {
+ return Promise.reject('Must supply a provider for popup or redirect sign in.');
+ }
return this._handleSignIn(method.call(this.auth, provider));
},