Closed xycloud closed 8 years ago
Is your code in a public repository?
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);
});
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...
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.
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.
I open the same route in different two browsers, but I got the sample
request.yar.id
; is that normal?