Custom fields for Credentials Provider
See original GitHub issueDescribe the feature
I would like to suggest a custom/optional field in the user interface object to store additional data. F.e when logging in with Strapi using Credential flow, the server will return a JWT. This token needs to stay unaltered otherwise the secret is no longer valid. I would like to propose a extra optional field for users, so that they can add in content that can be then safely stored within the encoded session jwt. By using getToken in Nitro we could then reacquire the original raw JWT token from Strapi.
Additional information
Within the […].ts auth catch all endpoint:
`if (user) {
const u = {
id: user.id,
name: user.user.username,
// Passing the OG JWT through the email field.
email: user.jwt
};
return u;
} else {
// If you return null then an error will be displayed advising the user to check their details.
return null;
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
}`
And then in Nitro Api I hack it out the email field currently with getToken: `const token = await getToken({ event });
const settings = {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token.email,
},
};`
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Using Credentials provider with a custom backend in ...
Using Credentials provider with a custom backend in NextAuth.js! ... Shown below the input field in my example setEmail(router.query.email) ...
Read more >Custom Login Experiences: Credential Providers in Windows ...
Create Custom Login Experiences With Credential Providers For Windows ... Credential::GetStringValue (dwFieldID = 2; password field) 21.
Read more >Use Custom Fields to Run Provider Searches - Salesforce Help
To create a custom field for use in provider search: From Object Manager, find and select Care Provider Searchable Field. Create a text...
Read more >Credentials | NextAuth.js
The Credentials provider allows you to handle signing in with arbitrary credentials, such as a username and password, domain, or two factor ...
Read more >Custom credential provider for *additional* authentication ...
In my case the only accessible for user field is "password type" edit for entering PIN-code. As a result my CP serialize user's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hey @jorgv, Hey @darwebdb,
this is a question that has been answered by @JoaoPedroAS51 here: https://github.com/sidebase/nuxt-auth/issues/61#issuecomment-1330946022
It will also be part of our documentation once #90 is merged: https://sidebase.io/nuxt-auth/recipes/custom-session-data
I’m closing this issue for now, please open a new one if there’s any further need for clarification (:
Thanks to both of you (:
Thanks for your reply @BracketJohn
I am using a similar situation like @darwebdb. We have a remote backend, so we use the credentials provider. We authenticate the user and we get a token and the user information as response:
In the authorize function from the credentials provider, I can pass only name, email and image. So like @darwebdb I am passing the backend token to the image field in order to access it after with the useSession and getSession
So, my question is how can I store the rest of the response fields in the session, can I do it during the authorize function? or how can I pass it to a callback so I can store it.
Or is it better to extend the user interface with the fields that I need, if this is the best way how do I replace the typeinterface for the custom one, as the link you provided from AuthNext I already have the custom type/next-auth.ts file but I am not sure how to replace it in the module.
thanks