Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. .config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider, $rootScope) {
  2. $urlRouterProvider.otherwise('signin');
  3. $stateProvider.state('site', {
  4. 'abstract': true,
  5. resolve: {
  6. authorize: ['authorization', function (authorization) {
  7. return authorization.authorize();
  8. }, ]
  9. }
  10. })
  11. .state('signin', {
  12. parent: 'site',
  13. url: '/signin',
  14. data: {
  15. roles: (function () {
  16. //principal.GetRoles(); --> in the below line i am returning hardcoded array value but i have take that array value from below principle factory
  17. return ['Dev','Admin'];
  18. })()
  19. },
  20. views: {
  21. '': { templateUrl: '/signin.html' },
  22. 'content@': {
  23. templateUrl: '/index.html',
  24. controller: 'SigninCtrl'
  25. }
  26. },
  27. })}
  28. ])
  29.  
  30. .factory('principal', ['$q', '$http', '$timeout', '$cookieStore', '$cookies', function ($q, $http, $timeout, $cookieStore, $cookies) {
  31. var _identity = undefined,
  32. _authenticated = false;
  33.  
  34. return {
  35. isIdentityResolved: function () {
  36. return angular.isDefined(_identity);
  37. },
  38. isAuthenticated: function () {
  39. return _authenticated;
  40. },
  41. RedirectUrl: function (absUrl) {
  42. $cookieStore.put('RedirectUrl', absUrl);
  43. return true;
  44. },
  45.  
  46. GetRoles: function () {
  47. return ['Dev','Admin']
  48. },
  49. }
  50. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement