Dan6erbond / sk-auth

Authentication library for use with SvelteKit featuring built-in OAuth providers and zero restriction customization!
MIT License
578 stars 70 forks source link

[Enhancement] Post Token Callback #64

Closed ByronCobb closed 2 years ago

ByronCobb commented 2 years ago

I've come across a scenario in which I would like to add additional information to the created token. I see there is a jwt callback, but I don't want to re-implement the cookie logic. It would be great if there was a callback that could manipulate the token just before it is saved to the cookie.

Something like this image

Thoughts?

Dan6erbond commented 2 years ago

Hmm. If I'm understanding what you want correctly, the JWT callback is the one you want. It's called JWT, but really what you're being given is the data in the JWT (see ./src/auth.ts) which you can change as you wish. It's a plain old JavaScript object that you can also modify the types of if you need to.