add organization management and refine source repository view
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-07-07 11:56:42 +09:00
parent 321b7c316e
commit 895e56088c
7 changed files with 268 additions and 0 deletions
+37
View File
@@ -15,6 +15,14 @@ type UserSessionRow = {
expiresAt: Date | null;
lastSeen: Date | null;
state: string;
primaryAffiliation: {
id: string;
organizationId: string;
organizationName: string;
organizationType: string;
department: string | null;
position: string | null;
} | null;
};
@Injectable()
@@ -43,10 +51,37 @@ export class UsersService {
},
orderBy: { createdAt: 'desc' },
},
affiliations: {
where: {
OR: [{ endsAt: null }, { endsAt: { gt: now } }],
},
orderBy: [{ isPrimary: 'desc' }, { createdAt: 'desc' }],
take: 1,
include: {
organization: {
select: {
id: true,
name: true,
type: true,
},
},
},
},
},
});
const rows: UserSessionRow[] = users.flatMap((user): UserSessionRow[] => {
const primaryAffiliation = user.affiliations[0]
? {
id: user.affiliations[0].id,
organizationId: user.affiliations[0].organizationId,
organizationName: user.affiliations[0].organization.name,
organizationType: user.affiliations[0].organization.type,
department: user.affiliations[0].department,
position: user.affiliations[0].position,
}
: null;
if (user.refreshTokens.length === 0) {
return [
{
@@ -61,6 +96,7 @@ export class UsersService {
expiresAt: null,
lastSeen: user.lastLoginAt,
state: user.isActive ? '세션 없음' : '잠김',
primaryAffiliation,
},
];
}
@@ -77,6 +113,7 @@ export class UsersService {
expiresAt: token.expiresAt,
lastSeen: user.lastLoginAt ?? token.createdAt,
state: getSessionState(user.isActive, token.revokedAt, token.expiresAt, now),
primaryAffiliation,
}));
});