(function(angular) {
  'use strict';

  angular
    .module('pm')
    .factory('userService', userService);

  userService.$inject = ['$sessionStorage'];

  function userService($sessionStorage) {
    $sessionStorage.$default({
      user: {}
    });

    var service = {
      get: get,
      isAuthenticated: isAuthenticated,
      isAuthorize: isAuthorize,
      register: register,
      signOut: signOut
    };

    return service;

    function get() {
      return $sessionStorage.user;
    }

    function isAuthenticated() {
      return angular.isDefined($sessionStorage.user.token);
    }

    function isAuthorize(rule) {
      // TODO: preparar para verificar autorização.
      return angular.isDefined(rule);
    }

    function register(newUser) {
      angular.merge($sessionStorage.user, newUser);
    }

    function signOut() {
      delete $sessionStorage.user.token;
    }
  }
})(angular);

@@ -129,23 +129,21 @@
 ct = %5B'$
-session
+local
 Storage'
@@ -170,23 +170,21 @@
 ervice($
-session
+local
 Storage)
@@ -191,23 +191,21 @@
  %7B%0A    $
-session
+local
 Storage.
@@ -218,23 +218,16 @@
 lt(%7B
-%0A      
 user: %7B%7D
 %0A   
@@ -222,21 +222,16 @@
 user: %7B%7D
-%0A    
 %7D);%0A%0A   
@@ -448,23 +448,21 @@
 return $
-session
+local
 Storage.
@@ -539,23 +539,21 @@
 efined($
-session
+local
 Storage.
@@ -756,23 +756,21 @@
 .merge($
-session
+local
 Storage.
@@ -835,15 +835,13 @@
 te $
-session
+local
 Stor

change storage for current user