aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/index.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-15 10:49:46 +0200
committerChocobozzz <me@florianbigard.com>2019-04-15 14:39:52 +0200
commit1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a (patch)
tree91a10310cdf924779527525d39f8eb7e09e4ba49 /server/controllers/api/users/index.ts
parent31b48aad478506d4214586f02792816efa968e4b (diff)
downloadPeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.tar.gz
PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.tar.zst
PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.zip
Add user adminFlags
Diffstat (limited to 'server/controllers/api/users/index.ts')
-rw-r--r--server/controllers/api/users/index.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index 28c8de303..0aafba66e 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -45,6 +45,7 @@ import { Notifier } from '../../../lib/notifier'
45import { mySubscriptionsRouter } from './my-subscriptions' 45import { mySubscriptionsRouter } from './my-subscriptions'
46import { CONFIG } from '../../../initializers/config' 46import { CONFIG } from '../../../initializers/config'
47import { sequelizeTypescript } from '../../../initializers/database' 47import { sequelizeTypescript } from '../../../initializers/database'
48import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
48 49
49const auditLogger = auditLoggerFactory('users') 50const auditLogger = auditLoggerFactory('users')
50 51
@@ -175,7 +176,8 @@ async function createUser (req: express.Request, res: express.Response) {
175 autoPlayVideo: true, 176 autoPlayVideo: true,
176 role: body.role, 177 role: body.role,
177 videoQuota: body.videoQuota, 178 videoQuota: body.videoQuota,
178 videoQuotaDaily: body.videoQuotaDaily 179 videoQuotaDaily: body.videoQuotaDaily,
180 adminFlags: body.adminFlags || UserAdminFlag.NONE
179 }) 181 })
180 182
181 const { user, account } = await createUserAccountAndChannelAndPlaylist(userToCreate) 183 const { user, account } = await createUserAccountAndChannelAndPlaylist(userToCreate)
@@ -241,7 +243,7 @@ async function blockUser (req: express.Request, res: express.Response) {
241} 243}
242 244
243function getUser (req: express.Request, res: express.Response) { 245function getUser (req: express.Request, res: express.Response) {
244 return res.json(res.locals.user.toFormattedJSON()) 246 return res.json(res.locals.user.toFormattedJSON({ withAdminFlags: true }))
245} 247}
246 248
247async function autocompleteUsers (req: express.Request, res: express.Response) { 249async function autocompleteUsers (req: express.Request, res: express.Response) {
@@ -253,7 +255,7 @@ async function autocompleteUsers (req: express.Request, res: express.Response) {
253async function listUsers (req: express.Request, res: express.Response) { 255async function listUsers (req: express.Request, res: express.Response) {
254 const resultList = await UserModel.listForApi(req.query.start, req.query.count, req.query.sort, req.query.search) 256 const resultList = await UserModel.listForApi(req.query.start, req.query.count, req.query.sort, req.query.search)
255 257
256 return res.json(getFormattedObjects(resultList.data, resultList.total)) 258 return res.json(getFormattedObjects(resultList.data, resultList.total, { withAdminFlags: true }))
257} 259}
258 260
259async function removeUser (req: express.Request, res: express.Response) { 261async function removeUser (req: express.Request, res: express.Response) {
@@ -278,6 +280,7 @@ async function updateUser (req: express.Request, res: express.Response) {
278 if (body.videoQuota !== undefined) userToUpdate.videoQuota = body.videoQuota 280 if (body.videoQuota !== undefined) userToUpdate.videoQuota = body.videoQuota
279 if (body.videoQuotaDaily !== undefined) userToUpdate.videoQuotaDaily = body.videoQuotaDaily 281 if (body.videoQuotaDaily !== undefined) userToUpdate.videoQuotaDaily = body.videoQuotaDaily
280 if (body.role !== undefined) userToUpdate.role = body.role 282 if (body.role !== undefined) userToUpdate.role = body.role
283 if (body.adminFlags !== undefined) userToUpdate.adminFlags = body.adminFlags
281 284
282 const user = await userToUpdate.save() 285 const user = await userToUpdate.save()
283 286