feat: split settings management pages
This commit is contained in:
@@ -341,7 +341,7 @@ export async function loginWithPassword(input: {
|
||||
.from(memberships)
|
||||
.innerJoin(organizations, eq(organizations.id, memberships.organizationId))
|
||||
.innerJoin(roles, eq(roles.id, memberships.roleId))
|
||||
.where(and(eq(memberships.accountId, account.id), eq(memberships.status, "active")))
|
||||
.where(and(eq(memberships.accountId, account.id), eq(memberships.status, "active"), eq(roles.isEnabled, true)))
|
||||
.limit(1);
|
||||
const membership = membershipRows[0];
|
||||
const expiresAt = new Date(Date.now() + SESSION_MAX_AGE_SECONDS * 1000);
|
||||
@@ -401,7 +401,7 @@ export async function getCurrentAuthContext(): Promise<AuthContext | null> {
|
||||
|
||||
const session = toSession(row.session);
|
||||
const platformRoleRows = row.account.platformRoleId
|
||||
? await database.select().from(roles).where(eq(roles.id, row.account.platformRoleId)).limit(1)
|
||||
? await database.select().from(roles).where(and(eq(roles.id, row.account.platformRoleId), eq(roles.isEnabled, true))).limit(1)
|
||||
: [];
|
||||
const platformRole = platformRoleRows[0];
|
||||
const organizationRows = row.session.activeOrganizationId
|
||||
@@ -418,6 +418,7 @@ export async function getCurrentAuthContext(): Promise<AuthContext | null> {
|
||||
eq(memberships.accountId, row.account.id),
|
||||
eq(memberships.organizationId, organizationRow.id),
|
||||
eq(memberships.status, "active"),
|
||||
eq(roles.isEnabled, true),
|
||||
),
|
||||
)
|
||||
.limit(1)
|
||||
|
||||
@@ -249,7 +249,11 @@ export async function getRoleDefinitions(organizationId?: string): Promise<RoleD
|
||||
|
||||
export async function getPermissionsForRole(roleId: string): Promise<Permission[]> {
|
||||
const database = getDatabase();
|
||||
const rows = await database.select().from(rolePermissions).where(eq(rolePermissions.roleId, roleId));
|
||||
const rows = await database
|
||||
.select({ permissionId: rolePermissions.permissionId })
|
||||
.from(rolePermissions)
|
||||
.innerJoin(roles, eq(roles.id, rolePermissions.roleId))
|
||||
.where(and(eq(rolePermissions.roleId, roleId), eq(roles.isEnabled, true)));
|
||||
return rows.map((row) => row.permissionId as Permission);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user