Added users 2FA statsu to userstable

This commit is contained in:
J. Newing 2025-07-08 10:12:20 -04:00
parent 2a6298e9eb
commit 0f3a5ce8ba
4 changed files with 41 additions and 6 deletions

View file

@ -49,7 +49,8 @@ async function queryUsers(orgId: string, limit: number, offset: number) {
roleName: roles.name,
isOwner: userOrgs.isOwner,
idpName: idp.name,
idpId: users.idpId
idpId: users.idpId,
twoFactorEnabled: users.twoFactorEnabled,
})
.from(users)
.leftJoin(userOrgs, eq(users.userId, userOrgs.userId))

View file

@ -34,6 +34,7 @@ export type UserRow = {
status: string;
role: string;
isOwner: boolean;
isTwoFactorEnabled: boolean;
};
type UsersTableProps = {
@ -170,6 +171,39 @@ export default function UsersTable({ users: u }: UsersTableProps) {
);
}
},
{
accessorKey: "isTwoFactorEnabled",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() =>
column.toggleSorting(column.getIsSorted() === "asc")
}
>
2FA Enabled
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
cell: ({ row }) => {
const userRow = row.original;
return (
<div className="flex flex-row items-center gap-2">
<span>{userRow.isTwoFactorEnabled && (
<span className="text-green-500">
{t('enabled')}
</span>
) || (
<span className="text-white/50">
{t('disabled')}
</span>
)}</span>
</div>
);
}
},
{
id: "actions",
cell: ({ row }) => {

View file

@ -45,9 +45,6 @@ import { useTranslations } from "next-intl";
export default function AccessControlsPage() {
const { orgUser: user, updateOrgUser } = userOrgUserContext();
console.log("User:", user);
const api = createApiClient(useEnvContext());
const { orgId } = useParams();
@ -224,7 +221,7 @@ export default function AccessControlsPage() {
<p className="text-xs text-muted-foreground ml-6">
When enabled, the user will be required to set up their authenticator app on their next login.
{user.twoFactorEnabled && (
<span className="text-blue-600"> This user currently has 2FA enabled.</span>
<span className="text-primary"> This user currently has 2FA enabled.</span>
)}
</p>
</div>
@ -246,6 +243,8 @@ export default function AccessControlsPage() {
</Button>
</SettingsSectionFooter>
</SettingsSection>
</SettingsContainer>
);
}

View file

@ -81,7 +81,8 @@ export default async function UsersPage(props: UsersPageProps) {
idpName: user.idpName || t('idpNameInternal'),
status: t('userConfirmed'),
role: user.isOwner ? t('accessRoleOwner') : user.roleName || t('accessRoleMember'),
isOwner: user.isOwner || false
isOwner: user.isOwner || false,
isTwoFactorEnabled: user.twoFactorEnabled || false,
};
});