Skip to content

Instantly share code, notes, and snippets.

@niisar
Created February 8, 2016 14:30
Show Gist options
  • Select an option

  • Save niisar/d63cf644849e5b6da6c1 to your computer and use it in GitHub Desktop.

Select an option

Save niisar/d63cf644849e5b6da6c1 to your computer and use it in GitHub Desktop.
AngularJSAuthentication.WEB
define(['app'], function (app) {
app.controller("mainCrl", function ($scope, $localStorage, $state) {
var authData = $localStorage.authorizationData;
console.log(authData)
if(authData) {
$scope.authentication = {
isAuth: true,
userName: authData.userName
};
}
$scope.$on('emitauthentication', function (event, args) {
$scope.authentication = {
isAuth: args.message.isAuth,
userName: args.message.userName
};
console.log(args)
});
$scope.logOut = function () {
delete $localStorage.authorizationData;
$scope.authentication = {
isAuth: false,
userName: ""
};
$state.go('home')
}
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment