New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use server.decorate()
instead of assignment
#104
Comments
Thanks @leesei I've seen it and have the work done locally. |
Thanks. |
👍 Struggling with how to access |
@jaw187 what are you trying to do, why do you need |
@mtharrison All of the code I'm assigning to server.ext('onPreAuth', (request, reply) => {
request.cookieAuth = {
set: function (session, value) {
if (arguments.length > 1) {
const key = session;
Hoek.assert(key && typeof key === 'string', 'Invalid session key');
session = request.auth.artifacts;
Hoek.assert(session, 'No active session to apply key to');
session[key] = value;
return reply.state(settings.cookie, session);
}
Hoek.assert(session && typeof session === 'object', 'Invalid session');
request.auth.artifacts = session;
reply.state(settings.cookie, session);
},
clear: function (key) {
if (arguments.length) {
Hoek.assert(key && typeof key === 'string', 'Invalid session key');
const session = request.auth.artifacts;
Hoek.assert(session, 'No active session to clear key from');
delete session[key];
return reply.state(settings.cookie, session);
}
request.auth.artifacts = null;
reply.unstate(settings.cookie);
},
ttl: function (msecs) {
const session = request.auth.artifacts;
Hoek.assert(session, 'No active session to modify ttl on');
reply.state(settings.cookie, session, { ttl: msecs });
}
};
return reply.continue();
}); I wrote some code where I included a function to register |
You just need to decorate once and then you can override the value later. The point is to register to avoid namepsace issues. |
Ok, great! |
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. |
See Eran's comment:
#103 (comment)
The text was updated successfully, but these errors were encountered: