Permalink
Browse files

Changed dependency cookie to cookies

  • Loading branch information...
1 parent c451f01 commit 7aa9f779c71beac5906386cde9d7fb08d9acc505 @fabien committed Feb 28, 2011
Showing with 10 additions and 7 deletions.
  1. +1 −1 lib/filter/remembermeauthenticationfilter.js
  2. +8 −5 lib/service/remembermeservice.js
  3. +1 −1 package.json
@@ -8,7 +8,7 @@ var RememberMeAuthenticationFilter = module.exports = function(options) {
RememberMeAuthenticationFilter.prototype.doFilter = function(request, response, callback) {
var Security = require('../security');
if (!Security.isAuthenticated(request)) {
- this.rememberMeService.autoLogin(request, function(user) {
+ this.rememberMeService.autoLogin(request, response, function(user) {
if (user) {
Security.setUser(request, user);
}
@@ -10,7 +10,7 @@
* }
*/
-require('cookie');
+require('cookies');
var COOKIE_NAME = 'connect_security_remember_me_cookie';
@@ -28,8 +28,9 @@ var RememberMeService = module.exports = function(options) {
this.parameter = options.rememberMe.parameter || 'rememberMe';
};
-RememberMeService.prototype.autoLogin = function(request, callback) {
- var token = request.getCookie(COOKIE_NAME);
+RememberMeService.prototype.autoLogin = function(request, response, callback) {
+ var cookies = new Cookies(request, response);
+ var token = cookies.get(COOKIE_NAME);
if (token) {
for (var i = 0; i < token.length % 4; i++) {
token = token + '=';
@@ -67,13 +68,15 @@ RememberMeService.prototype.loginSuccessful = function(request, response, callba
while (token[token.length - 1] === '=') {
token = token.substring(0, token.length - 1);
}
- response.setCookie(COOKIE_NAME, token, {expires: new Date(validTo)});
+ var cookies = new Cookies(request, response);
+ cookies.set(COOKIE_NAME, token, { expires: new Date(validTo) });
}
callback();
};
RememberMeService.prototype.logoutSuccessful = function(request, response, callback) {
- response.clearCookie(COOKIE_NAME);
+ var cookies = new Cookies(request, response);
+ cookies.set(COOKIE_NAME);
callback();
};
View
@@ -11,7 +11,7 @@
},
"dependencies": {
"connect": ">= 0.2.5",
- "cookie": ">= 0.1.2",
+ "cookies": ">= 0.1.5",
"vows": ">= 0.5.6"
},
"directories": {

0 comments on commit 7aa9f77

Please sign in to comment.