Inviting a teammate with nextAuth

Hi guys, in [...nextAuth], the email provider is working nicely:
EmailProvider({
sendVerificationRequest(params: SendVerificationRequestParams) {
const { identifier: email, url, expires } = params;
const newParams = { ...mailjetParams, email, url };
newParams.email = params.identifier;
sendEmailWithMailjet(newParams as SendWithMailjetProps);
},
}),
EmailProvider({
sendVerificationRequest(params: SendVerificationRequestParams) {
const { identifier: email, url, expires } = params;
const newParams = { ...mailjetParams, email, url };
newParams.email = params.identifier;
sendEmailWithMailjet(newParams as SendWithMailjetProps);
},
}),
Now i want to add invite team members functionality. How can I trigger this from the server side?
23 Replies
fotoflo
fotoflo17mo ago
can i just grab import EmailProvider from "next-auth/providers/email";. anywhere in teh application? ... lets see what happens didnt work
arete
arete17mo ago
do you want to make a whitelist?
theo
theo17mo ago
"invite a teammate" is a complex enough concept that you'd be rolling it yourself Do you want teams functionality? Like teams with shared permission sets and such?
theo
theo17mo ago
If clerk has this built in I'd just use that tbh https://clerk.dev/?ref=theo
Clerk
Clerk | Authentication and User Management
The easiest way to add authentication and user management to your application. Purpose-built for React, Next.js, Remix, and “The Modern Web”.
fotoflo
fotoflo17mo ago
itneresting thanks i created teams and roles already i just wanted to trigger sendAuthentioRequest to send an email that has a token wasnt sure if thats possible, will checkout clerk thank you @theo @Devastated no i dont think thats what im after
theo
theo17mo ago
You can't send an authentication request for a user who doesn't exist
fotoflo
fotoflo17mo ago
i actually create the user first that's done
theo
theo17mo ago
...I don't recommend creating users without the user authing Basically asking for a split brain problem
fotoflo
fotoflo17mo ago
but not the accounts accounts Account[] sessions Session[]
theo
theo17mo ago
I've shared all I have, I'm out. Pls dont @ me
fotoflo
fotoflo17mo ago
what is splitbrain problem?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo17mo ago
thanks. How do i pass a token across login? i re-archtected this... sending them to the login page with a token,
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo17mo ago
in most flows ive seen the user accepts the invite by clicking a fully formed link with a token in an email that takes them to login they login, and the token is passed with the oauth or email login
barry
barry17mo ago
Yeah seems like a good approach
fotoflo
fotoflo17mo ago
but how do you pass the invite token across the next-auth boundry? cc @barry @Nedi ? i got the invite token and i figured out how to pass it through google auth! i think it looks like i send them through a page like nedi suggested. maybe just a redirect
Diogo
Diogo17mo ago
Take a look at dub.sh it's open-source and ut has team functionality
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo17mo ago
i did that, its working... 🙂 thank you! i think im almost there. would have been way beter to just hijack the emailProvider functionality
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo16mo ago
its kind of irrelevant at this point... this is how it does work