mirror of
https://github.com/outline/outline.git
synced 2026-12-04 10:24:43 +03:00
fix: Show api-key creator name in settings page (#10041)
This commit is contained in:
1 parent
ac55ad55dd
commit
05b9c69da8
4 files changed
+11
-1
No files matched your search
@@ -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 })}{" "}
|
||||
·{" "}
|
||||
</Text>
|
||||
{apiKey.lastActiveAt && (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -34,6 +34,8 @@ router.post(
|
||||
scope: scope?.map((s) => (s.startsWith("/api/") ? s : `/api/${s}`)),
|
||||
});
|
||||
|
||||
apiKey.user = user;
|
||||
|
||||
ctx.body = {
|
||||
data: presentApiKey(apiKey),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user