Skip to content

Commit

Permalink
Merge pull request #1092 from pixelducky/master
Browse files Browse the repository at this point in the history
refactor(client:auth): use $cookies instead
  • Loading branch information
Awk34 committed Jul 28, 2015
2 parents 8766341 + ca3abd9 commit 18b0f5c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/templates/client/components/auth(auth)/auth.service(js).js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

angular.module('<%= scriptAppName %>')
.factory('Auth', function Auth($location, $rootScope, $http, User, $cookieStore, $q) {
.factory('Auth', function Auth($location, $rootScope, $http, User, $cookies, $q) {
var currentUser = {};
if($cookieStore.get('token')) {
if($cookies.get('token')) {
currentUser = User.get();
}

Expand All @@ -25,7 +25,7 @@ angular.module('<%= scriptAppName %>')
password: user.password
}).
success(function(data) {
$cookieStore.put('token', data.token);
$cookies.put('token', data.token);
currentUser = User.get();
deferred.resolve(data);
return cb();
Expand All @@ -45,7 +45,7 @@ angular.module('<%= scriptAppName %>')
* @param {Function}
*/
logout: function() {
$cookieStore.remove('token');
$cookies.remove('token');
currentUser = {};
},

Expand All @@ -61,7 +61,7 @@ angular.module('<%= scriptAppName %>')

return User.save(user,
function(data) {
$cookieStore.put('token', data.token);
$cookies.put('token', data.token);
currentUser = User.get();
return cb(user);
},
Expand Down Expand Up @@ -140,7 +140,7 @@ angular.module('<%= scriptAppName %>')
* Get auth token
*/
getToken: function() {
return $cookieStore.get('token');
return $cookies.get('token');
}
};
});

0 comments on commit 18b0f5c

Please sign in to comment.