You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cache.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Created by robin on 11/1/15.
  3. */
  4. (function () {
  5. 'use strict';
  6. angular.module('luticateAuth')
  7. .factory('luticateAuthCache', ['localStorageService', function (localStorageService) {
  8. var luticateAuthCache = {};
  9. luticateAuthCache.setUser = function(user)
  10. {
  11. localStorageService.set('lu_user', user);
  12. };
  13. luticateAuthCache.getUser = function()
  14. {
  15. return localStorageService.get('lu_user');
  16. };
  17. luticateAuthCache.getToken = function()
  18. {
  19. var user = luticateAuthCache.getUser();
  20. if (user == null) {
  21. return null;
  22. }
  23. return user.Token;
  24. };
  25. luticateAuthCache.removeUser = function()
  26. {
  27. localStorageService.remove('lu_user');
  28. luticateAuthCache.removeEffectivePermissions();
  29. };
  30. luticateAuthCache.setEffectivePermissions = function(permissions)
  31. {
  32. localStorageService.set('lu_effective_permissions', permissions);
  33. };
  34. luticateAuthCache.getEffectivePermissions = function()
  35. {
  36. return localStorageService.get('lu_effective_permissions');
  37. };
  38. luticateAuthCache.removeEffectivePermissions = function()
  39. {
  40. localStorageService.remove('lu_effective_permissions');
  41. };
  42. return luticateAuthCache;
  43. }]);
  44. })();