aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users')
-rw-r--r--server/controllers/api/users/index.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index 01ee73a53..faba7e208 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -18,6 +18,7 @@ import {
18 setDefaultPagination, 18 setDefaultPagination,
19 setDefaultSort, 19 setDefaultSort,
20 token, 20 token,
21 userAutocompleteValidator,
21 usersAddValidator, 22 usersAddValidator,
22 usersGetValidator, 23 usersGetValidator,
23 usersRegisterValidator, 24 usersRegisterValidator,
@@ -51,6 +52,11 @@ const askSendEmailLimiter = new RateLimit({
51const usersRouter = express.Router() 52const usersRouter = express.Router()
52usersRouter.use('/', meRouter) 53usersRouter.use('/', meRouter)
53 54
55usersRouter.get('/autocomplete',
56 userAutocompleteValidator,
57 asyncMiddleware(autocompleteUsers)
58)
59
54usersRouter.get('/', 60usersRouter.get('/',
55 authenticate, 61 authenticate,
56 ensureUserHasRight(UserRight.MANAGE_USERS), 62 ensureUserHasRight(UserRight.MANAGE_USERS),
@@ -222,6 +228,12 @@ function getUser (req: express.Request, res: express.Response, next: express.Nex
222 return res.json((res.locals.user as UserModel).toFormattedJSON()) 228 return res.json((res.locals.user as UserModel).toFormattedJSON())
223} 229}
224 230
231async function autocompleteUsers (req: express.Request, res: express.Response, next: express.NextFunction) {
232 const resultList = await UserModel.autocomplete(req.query.search as string)
233
234 return res.json(resultList)
235}
236
225async function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) { 237async function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) {
226 const resultList = await UserModel.listForApi(req.query.start, req.query.count, req.query.sort) 238 const resultList = await UserModel.listForApi(req.query.start, req.query.count, req.query.sort)
227 239