Created
February 12, 2015 06:12
-
-
Save bioball/076b19581f128afe2d0e to your computer and use it in GitHub Desktop.
Angular AUTH example
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
angular.module('app') | |
.factory('authentication', [ | |
'user', | |
function(user){ | |
return { | |
authentication: function(){ | |
return user.identify(); | |
} | |
}; | |
} | |
]); |
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
angular.module('app') | |
.config([ | |
'$stateProvider', | |
function($stateProvider){ | |
$stateProvider | |
.state('home', { | |
url: '/', | |
resolve: { | |
isLoggedIn: { | |
[ | |
'authentication', | |
function(authentication){ | |
return authentication.authenticate(); | |
} | |
] | |
} | |
} | |
} | |
]) |
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
angular.module('app') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment