hapijs / yar

A hapi session manager
Other
133 stars 59 forks source link

same request.yar.id of different request #97

Closed xycloud closed 8 years ago

xycloud commented 8 years ago

I open the same route in different two browsers, but I got the sample request.yar.id; is that normal?

mark-bradshaw commented 8 years ago

Is your code in a public repository?

xycloud commented 8 years ago

register like below:

      server.register({
        register: require('yar'),
        options: {
          storeBlank: false,
          cookieOptions: {
              password: 'the-password-must-be-at-least-32-characters-lonxxxg',
              isSecure: false,
              isHttpOnly: true,
              ttl: 24 * 3600
          }
      }}, (err) => {});

//route of setting token

      server.route({
        path: '/register',
        method: 'GET',
        handler: function(request, reply) {
          var token = request.query.TOKEN;
          var next  = request.query.NEXT;
          request.yar.set('token', token);
          return reply.redirect(next);
        }
      });

add onPostAuth point:

      server.ext('onPostAuth', function(request, reply) {
        console.log(request.yar.id);
        var token = request.yar.get('token');
        if (!token) {
          //invalid
          return reply.redirect('/register')    
       }
        return reply.continue();
      }, (err) => {
        console.log(err);
      });
xycloud commented 8 years ago

i clear all the cookie in chrome, but i can still get the same request.yar.id and request.yar.get('token'), that's crazy...

mark-bradshaw commented 8 years ago

I've verified that this code is working just fine. The most likely explanation is that cookies aren't actually getting cleared. Try using a different browser entirely to make sure you are getting a different request.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.