aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r--server/controllers/api/users.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 845facd55..e79480521 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -17,7 +17,7 @@ import {
17 setUsersSort, 17 setUsersSort,
18 token 18 token
19} from '../../middlewares' 19} from '../../middlewares'
20import { UserVideoRate as FormatedUserVideoRate } from '../../../shared' 20import { UserVideoRate as FormatedUserVideoRate, UserCreate, UserUpdate } from '../../../shared'
21 21
22const usersRouter = express.Router() 22const usersRouter = express.Router()
23 23
@@ -78,10 +78,12 @@ export {
78// --------------------------------------------------------------------------- 78// ---------------------------------------------------------------------------
79 79
80function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { 80function createUser (req: express.Request, res: express.Response, next: express.NextFunction) {
81 const body: UserCreate = req.body
82
81 const user = db.User.build({ 83 const user = db.User.build({
82 username: req.body.username, 84 username: body.username,
83 password: req.body.password, 85 password: body.password,
84 email: req.body.email, 86 email: body.email,
85 displayNSFW: false, 87 displayNSFW: false,
86 role: USER_ROLES.USER 88 role: USER_ROLES.USER
87 }) 89 })
@@ -132,10 +134,12 @@ function removeUser (req: express.Request, res: express.Response, next: express.
132} 134}
133 135
134function updateUser (req: express.Request, res: express.Response, next: express.NextFunction) { 136function updateUser (req: express.Request, res: express.Response, next: express.NextFunction) {
137 const body: UserUpdate = req.body
138
135 db.User.loadByUsername(res.locals.oauth.token.user.username) 139 db.User.loadByUsername(res.locals.oauth.token.user.username)
136 .then(user => { 140 .then(user => {
137 if (req.body.password) user.password = req.body.password 141 if (body.password) user.password = body.password
138 if (req.body.displayNSFW !== undefined) user.displayNSFW = req.body.displayNSFW 142 if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW
139 143
140 return user.save() 144 return user.save()
141 }) 145 })