Skip to content

Commit aa16e4c

Browse files
Copilotfiftin
andcommitted
Fix potential slice out-of-bounds error in API token display
Co-authored-by: fiftin <[email protected]>
1 parent b2d8ae3 commit aa16e4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

api/user.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ func getAPITokens(w http.ResponseWriter, r *http.Request) {
5252
}
5353

5454
for i := range tokens {
55-
tokens[i].ID = tokens[i].ID[:8]
55+
if len(tokens[i].ID) >= 8 {
56+
tokens[i].ID = tokens[i].ID[:8]
57+
}
58+
// If ID is shorter than 8 chars, leave it as-is
5659
}
5760

5861
helpers.WriteJSON(w, http.StatusOK, tokens)

0 commit comments

Comments
 (0)