-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add session to endpoints #4068
Comments
Well, you have |
I suppose I understand that a workaround is possible. But I'm advocating for a more explicit way. |
getSession gets run after handle hook, and getSession is mostly used to filter what's safe(from locals) to send the client as session, so for ex. you have locals.password export function getSession({ locals }){
delete locals.password;
return locals;
} |
I'm going to close this as As mentioned, it's typical for export const getSession = ({ locals }) => locals.session; export function getSession({ locals }) {
// locals.user contains secrets like 'token' or whatever
return {
user: locals.user && {
name: locals.user.name,
avatar: locals.user.avatar
}
};
} |
Describe the problem
Endpoints need to have access to user session to perform actions. Right now, you have to reimplement/import session management in endpoints.
Describe the proposed solution
Why not just expose
session
as part ofRequest
to endpoints. We are already runninggetSession
for pages. Let's run it for endpoints as well and have the results available inRequestEvent
to endpoint handlers. e.g.Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: