Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a27a8f0

Browse files
committed
refactor: name null users in audit logs
1 parent 5285c12 commit a27a8f0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,12 @@ export const SCIMUpdateUser: Story = {
105105
},
106106
},
107107
};
108+
109+
export const UnauthenticatedUser: Story = {
110+
args: {
111+
auditLog: {
112+
...MockAuditLog,
113+
user: null,
114+
},
115+
},
116+
};

site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export const AuditLogDescription: FC<AuditLogDescriptionProps> = ({
1919
}
2020

2121
let target = auditLog.resource_target.trim();
22-
let user = auditLog.user?.username.trim();
22+
let user = auditLog.user
23+
? auditLog.user.username.trim()
24+
: "Unauthenticated user";
2325

2426
// SSH key entries have no links
2527
if (auditLog.resource_type === "git_ssh_key") {

site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/BuildAuditDescription.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const BuildAuditDescription: FC<BuildAuditDescriptionProps> = ({
1616
auditLog.additional_fields?.build_reason &&
1717
auditLog.additional_fields?.build_reason !== "initiator"
1818
? "Coder automatically"
19-
: auditLog.user?.username.trim();
19+
: auditLog.user
20+
? auditLog.user.username.trim()
21+
: "Unauthenticated user";
2022

2123
const action = useMemo(() => {
2224
switch (auditLog.action) {

0 commit comments

Comments
 (0)