reiji-h 1 год назад
Родитель
Сommit
5e7f9a738e

+ 1 - 0
apps/app/src/server/models/user.js

@@ -69,6 +69,7 @@ const factory = (crowi) => {
     introduction: String,
     password: String,
     apiToken: { type: String, index: true },
+    accessTokens: { type: mongoose.Schema.Types.ObjectId, ref: 'AccessToken' },
     lang: {
       type: String,
       enum: i18n.locales,

+ 9 - 0
packages/core/src/interfaces/access-token.ts

@@ -0,0 +1,9 @@
+import type { Types } from 'mongoose';
+
+export type IAccessToken = {
+  userId: Types.ObjectId,
+  tokenHash: string,
+  expiredAt: Date,
+  scope: string[],
+  description: string,
+}

+ 2 - 0
packages/core/src/interfaces/user.ts

@@ -1,3 +1,4 @@
+import type { IAccessToken } from './access-token';
 import type { IAttachment } from './attachment';
 import type { Ref } from './common';
 import type { HasObjectId } from './has-object-id';
@@ -15,6 +16,7 @@ export type IUser = {
   admin: boolean,
   readOnly: boolean,
   apiToken?: string,
+  accessToken?: Ref<IAccessToken>,
   isEmailPublished: boolean,
   isInvitationEmailSended: boolean,
   lang: Lang,