Experiencing an issue with Angular authentication using ng-token-auth
. The Sign Out button is not displaying after successful Sign Up, although it works fine for Sign In.
I have checked my code and the isLoggedIn()
and signOut()
functions are working as expected without any errors.
Could someone please point out where I might be going wrong? Thank you!
Navbar Controller
function($rootScope, $scope, $location, $auth, currentUser) {
$scope.isLoggedIn = function() {
return ($scope.user.id) ? true : false;
}
$scope.signOut = function() {
currentUser.signOut();
};
Auth Controller
$scope.submitRegistration = function() {
$auth.submitRegistration($scope.registrationForm)
.then(function(res) {
currentUser.set(res.data.data);
$scope.close();
})
.catch(function(res) {
$scope.errors = res.data.errors.full_messages.join(', ');
})
};
$scope.submitLogin = function() {
$auth.submitLogin($scope.loginForm)
.then(function(resp) {
currentUser.set(resp);
$scope.close();
})
.catch(function(resp) {
$scope.errors = "Email or Password invalid...";
});
};
Navbar HTML
<li ng-controller="AuthModalCtrl" ng-if='!isLoggedIn()'>
<div ng-click="openModal(signin)">Sign In</div>
</li>
<li ng-controller="AuthModalCtrl" ng-if='!isLoggedIn()'>
<div class="bubble-btn sign-up" ng-click="openModal('register')">Sign Up</div>
</li>
<li ng-controller="NavCtrl" ng-show='isLoggedIn()'>
<div ng-click="signOut()">Sign Out</div>
</li>