diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 20:07:54 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 20:07:54 +0200 |
commit | b0f9f39ed70299a208d1b388c72de8b7f3510cb7 (patch) | |
tree | 4b7d388125265533ac2f6d4bf457d018617e1db6 /server/controllers/api | |
parent | e7dbeae8d915cdf4470ceb51c2724b04148b30b5 (diff) | |
download | PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.tar.gz PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.tar.zst PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.zip |
Begin user quota
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/users.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 04d885185..1b5b7f903 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | 2 | ||
3 | import { database as db } from '../../initializers/database' | 3 | import { database as db } from '../../initializers/database' |
4 | import { USER_ROLES } from '../../initializers' | 4 | import { USER_ROLES, CONFIG } from '../../initializers' |
5 | import { logger, getFormattedObjects } from '../../helpers' | 5 | import { logger, getFormattedObjects } from '../../helpers' |
6 | import { | 6 | import { |
7 | authenticate, | 7 | authenticate, |
@@ -80,12 +80,18 @@ export { | |||
80 | function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { | 80 | function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { |
81 | const body: UserCreate = req.body | 81 | const body: UserCreate = req.body |
82 | 82 | ||
83 | // On registration, we set the user video quota | ||
84 | if (body.videoQuota === undefined) { | ||
85 | body.videoQuota = CONFIG.USER.VIDEO_QUOTA | ||
86 | } | ||
87 | |||
83 | const user = db.User.build({ | 88 | const user = db.User.build({ |
84 | username: body.username, | 89 | username: body.username, |
85 | password: body.password, | 90 | password: body.password, |
86 | email: body.email, | 91 | email: body.email, |
87 | displayNSFW: false, | 92 | displayNSFW: false, |
88 | role: USER_ROLES.USER | 93 | role: USER_ROLES.USER, |
94 | videoQuota: body.videoQuota | ||
89 | }) | 95 | }) |
90 | 96 | ||
91 | user.save() | 97 | user.save() |
@@ -140,6 +146,7 @@ function updateUser (req: express.Request, res: express.Response, next: express. | |||
140 | .then(user => { | 146 | .then(user => { |
141 | if (body.password) user.password = body.password | 147 | if (body.password) user.password = body.password |
142 | if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW | 148 | if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW |
149 | if (body.videoQuota !== undefined) user.videoQuota = body.videoQuota | ||
143 | 150 | ||
144 | return user.save() | 151 | return user.save() |
145 | }) | 152 | }) |