Skip to content

Commit 18b0f5c

Browse files
committed
Merge pull request angular-fullstack#1092 from pixelducky/master
refactor(client:auth): use $cookies instead
2 parents 8766341 + ca3abd9 commit 18b0f5c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: app/templates/client/components/auth(auth)/auth.service(js).js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.factory('Auth', function Auth($location, $rootScope, $http, User, $cookieStore, $q) {
4+
.factory('Auth', function Auth($location, $rootScope, $http, User, $cookies, $q) {
55
var currentUser = {};
6-
if($cookieStore.get('token')) {
6+
if($cookies.get('token')) {
77
currentUser = User.get();
88
}
99

@@ -25,7 +25,7 @@ angular.module('<%= scriptAppName %>')
2525
password: user.password
2626
}).
2727
success(function(data) {
28-
$cookieStore.put('token', data.token);
28+
$cookies.put('token', data.token);
2929
currentUser = User.get();
3030
deferred.resolve(data);
3131
return cb();
@@ -45,7 +45,7 @@ angular.module('<%= scriptAppName %>')
4545
* @param {Function}
4646
*/
4747
logout: function() {
48-
$cookieStore.remove('token');
48+
$cookies.remove('token');
4949
currentUser = {};
5050
},
5151

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

6262
return User.save(user,
6363
function(data) {
64-
$cookieStore.put('token', data.token);
64+
$cookies.put('token', data.token);
6565
currentUser = User.get();
6666
return cb(user);
6767
},
@@ -140,7 +140,7 @@ angular.module('<%= scriptAppName %>')
140140
* Get auth token
141141
*/
142142
getToken: function() {
143-
return $cookieStore.get('token');
143+
return $cookies.get('token');
144144
}
145145
};
146146
});

0 commit comments

Comments
 (0)