fix: Show api-key creator name in settings page (#10041)

This commit is contained in:
Hemachandar authored and GitHub committed 2025-08-29 19:03:47 +05:30
1 parent ac55ad55dd
commit 05b9c69da8
4 files changed
+11 -1

No files matched your search

+6
View File
@@ -2,6 +2,8 @@ import { isPast } from "date-fns";
import { computed, observable } from "mobx";
import ParanoidModel from "./base/ParanoidModel";
import Field from "./decorators/Field";
import User from "./User";
import Relation from "./decorators/Relation";
class ApiKey extends ParanoidModel {
static modelName = "ApiKey";
@@ -25,6 +27,10 @@ class ApiKey extends ParanoidModel {
@observable
lastActiveAt?: string;
/** The user who this API key belongs to. */
@Relation(() => User)
user: User;
/** The user ID that the API key belongs to. */
userId: string;
@@ -32,7 +32,7 @@ const ApiKeyListItem = ({ apiKey }: Props) => {
{t(`Created`)} <Time dateTime={apiKey.createdAt} addSuffix />{" "}
{apiKey.userId === user.id
? ""
: t(`by {{ name }}`, { name: user.name })}{" "}
: t(`by {{ name }}`, { name: apiKey.user.name })}{" "}
&middot;{" "}
</Text>
{apiKey.lastActiveAt && (
+2
View File
@@ -1,8 +1,10 @@
import ApiKey from "@server/models/ApiKey";
import presentUser from "./user";
export default function presentApiKey(apiKey: ApiKey) {
return {
id: apiKey.id,
user: presentUser(apiKey.user),
userId: apiKey.userId,
name: apiKey.name,
scope: apiKey.scope,
+2
View File
@@ -34,6 +34,8 @@ router.post(
scope: scope?.map((s) => (s.startsWith("/api/") ? s : `/api/${s}`)),
});
apiKey.user = user;
ctx.body = {
data: presentApiKey(apiKey),
};