Created
February 8, 2016 14:30
-
-
Save niisar/d63cf644849e5b6da6c1 to your computer and use it in GitHub Desktop.
AngularJSAuthentication.WEB
This file contains hidden or 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
| 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