Created
July 14, 2017 18:03
-
-
Save vinceyoumans/ba94d7c8bcb13784a79d105cb05b6375 to your computer and use it in GitHub Desktop.
Polymer authentication demo... Not working for me.. .but I did some experimentation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="my-app.html"> | |
<link rel="import" href="bower_componenets/polymerfire/firebase-auth.html"> | |
<link rel="import" href="bower_componenets/paper-button/Paper-button.html"> | |
<dom-module id="my-login"> | |
<template> | |
<firebase-auth | |
id="auth" | |
user="{{user}}" | |
status-known="{{statusKnown}}" | |
provider="google" | |
on-error="handleError"> | |
</firebase-auth> | |
<template is="dom-if" if="[[user]]"> | |
<h1>Welcome [[user.displayName]]</h1> | |
</template> | |
<paper-button raised on-tap="login" hidden$="[[user]]"> Sign in</paper-button> | |
<paper-button raised on-tap="logout" hidden$="[[!user]]"> Sign Out</paper-button> | |
</template> | |
<script> | |
Polymer({ | |
is: 'my-login', | |
properties:{ | |
user: { | |
type: Object | |
}, | |
statusKnown:{ | |
type: Object | |
} | |
}, | |
login(){ | |
// return this.$.auth.signInWithPopup(); // not working. this was original line... | |
return this.$.auth.signInWithPopup() | |
.then(function(response) {}) // successful authentication response here}) | |
.catch(function(error) {}); // unsuccessful authentication response here}); | |
}, | |
logout(){ | |
return this.$.auth.signOut(); | |
} | |
}); | |
</script> | |
</dom-module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment