Skip to content

Instantly share code, notes, and snippets.

@sejr
Last active July 1, 2016 19:29
Show Gist options
  • Select an option

  • Save sejr/a3f21bd2b42dbab8b1dd44375e88f8ce to your computer and use it in GitHub Desktop.

Select an option

Save sejr/a3f21bd2b42dbab8b1dd44375e88f8ce to your computer and use it in GitHub Desktop.
controller: function($scope, $state) {
$scope.fetchUser = function() {
$scope.user = firebase.auth().currentUser;
console.log("fetchUser() returns " + $scope.user);
};
$scope.isAuthenticated = function() {
if (firebase.auth().currentUser) {
return true;
}
return false;
};
$scope.deauth = function() {
console.log('Deauth called');
firebase.auth().signOut().then(function() {
$state.go($state.current, {}, {reload: true});
}, function(error) {
// An error happened.
console.log(error);
});
};
$scope.fetchUser();
}
<div class="col-lg-3 col-jnxn" id="jnxn-messaging">
<div class="card" ng-show="isAuthenticated()">
{{ user }}
<hr>
<button type="button" ng-click="deauth()" id="btn-join" class="btn btn-default btn-lg btn-block">Sign out</button>
</div>
<div class="card" ng-hide="isAuthenticated()">
<div class="ad" id="junction-ad">
<h4>Welcome to Junction!</h4>
<p>
{{ user }}
</p>
</div>
<hr>
<button type="submit" ui-sref="auth" id="btn-signin" class="btn btn-default btn-lg btn-block">Sign in</button>
<button type="button" ui-sref="auth" id="btn-join" class="btn btn-default btn-lg btn-block">Join for free</button>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment