set beta user if invites available
This commit is contained in:
@@ -111,8 +111,22 @@ export const authOptions: NextAuthOptions = {
|
||||
},
|
||||
events: {
|
||||
createUser: async ({ user }) => {
|
||||
let invitesAvailable = false;
|
||||
|
||||
if (user.email) {
|
||||
const invites = await db.teamInvite.findMany({
|
||||
where: { email: user.email },
|
||||
});
|
||||
|
||||
invitesAvailable = invites.length > 0;
|
||||
}
|
||||
|
||||
// No waitlist for self hosting
|
||||
if (!env.NEXT_PUBLIC_IS_CLOUD || env.NODE_ENV === "development") {
|
||||
if (
|
||||
!env.NEXT_PUBLIC_IS_CLOUD ||
|
||||
env.NODE_ENV === "development" ||
|
||||
invitesAvailable
|
||||
) {
|
||||
await db.user.update({
|
||||
where: { id: user.id },
|
||||
data: { isBetaUser: true },
|
||||
|
Reference in New Issue
Block a user