feat: include org role in org session data (#14652)
* feat: include org role in org session data * update contents * remove: files
This commit is contained in:
1 parent
f6e45842fd
commit
dbbd78fb26
4 files changed
+65
-27
No files matched your search
@@ -511,6 +511,19 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||
}
|
||||
|
||||
const profileOrg = profile?.organization;
|
||||
let orgRole: MembershipRole | undefined;
|
||||
// Get users role of org
|
||||
if (profileOrg) {
|
||||
const membership = await prisma.membership.findUnique({
|
||||
where: {
|
||||
userId_teamId: {
|
||||
teamId: profileOrg.id,
|
||||
userId: existingUser.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
orgRole = membership?.role;
|
||||
}
|
||||
|
||||
return {
|
||||
...existingUserWithoutTeamsField,
|
||||
@@ -528,6 +541,7 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||
logoUrl: profileOrg.logoUrl,
|
||||
fullDomain: getOrgFullOrigin(profileOrg.slug ?? profileOrg.requestedSlug ?? ""),
|
||||
domainSuffix: subdomainSuffix(),
|
||||
role: orgRole as MembershipRole, // It can't be undefined if we have a profileOrg
|
||||
}
|
||||
: null,
|
||||
} as JWT;
|
||||
|
||||
Reference in new issue
Block a user