add organization management and refine source repository view
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -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,
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user