diff --git a/src/models/user.ts b/src/models/user.ts index fdbb245faa28df6c7cea0d3f04993de9c636844b..31d09bc8f829231cf52eaaa2653137e363c5bcd0 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -118,6 +118,7 @@ export interface IRemoteUser extends IUserBase { publicKeyPem: string; }; updatedAt: Date; + isAdmin: false; } export type IUser = ILocalUser | IRemoteUser; diff --git a/src/server/api/call.ts b/src/server/api/call.ts index e4bb30b695309c098374933d69ca557fefbe2357..c191701b027d3dfa65f71df9fdb5d09a096999e2 100644 --- a/src/server/api/call.ts +++ b/src/server/api/call.ts @@ -21,7 +21,7 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any) return rej('YOUR_ACCOUNT_HAS_BEEN_SUSPENDED'); } - if (ep.meta.requireAdmin && !(isLocalUser(user) && user.isAdmin)) { + if (ep.meta.requireAdmin && !user.isAdmin) { return rej('YOU_ARE_NOT_ADMIN'); } diff --git a/src/server/api/endpoints/admin/suspend-user.ts b/src/server/api/endpoints/admin/suspend-user.ts index 9c32ba987d2880df231980f73ee61fac104606a1..9b492c6e15f0b1ac5595fc04679ce865e252037c 100644 --- a/src/server/api/endpoints/admin/suspend-user.ts +++ b/src/server/api/endpoints/admin/suspend-user.ts @@ -34,6 +34,10 @@ export default (params: any) => new Promise(async (res, rej) => { return rej('user not found'); } + if (user.isAdmin) { + return rej('cannot suspend admin'); + } + await User.findOneAndUpdate({ _id: user._id }, {