mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Better typescript typing for a better world
This commit is contained in:
parent
7a214f746b
commit
4771e0008d
59 changed files with 400 additions and 166 deletions
|
@ -17,7 +17,7 @@ import {
|
|||
setUsersSort,
|
||||
token
|
||||
} from '../../middlewares'
|
||||
import { UserVideoRate as FormatedUserVideoRate } from '../../../shared'
|
||||
import { UserVideoRate as FormatedUserVideoRate, UserCreate, UserUpdate } from '../../../shared'
|
||||
|
||||
const usersRouter = express.Router()
|
||||
|
||||
|
@ -78,10 +78,12 @@ export {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createUser (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const body: UserCreate = req.body
|
||||
|
||||
const user = db.User.build({
|
||||
username: req.body.username,
|
||||
password: req.body.password,
|
||||
email: req.body.email,
|
||||
username: body.username,
|
||||
password: body.password,
|
||||
email: body.email,
|
||||
displayNSFW: false,
|
||||
role: USER_ROLES.USER
|
||||
})
|
||||
|
@ -132,10 +134,12 @@ function removeUser (req: express.Request, res: express.Response, next: express.
|
|||
}
|
||||
|
||||
function updateUser (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const body: UserUpdate = req.body
|
||||
|
||||
db.User.loadByUsername(res.locals.oauth.token.user.username)
|
||||
.then(user => {
|
||||
if (req.body.password) user.password = req.body.password
|
||||
if (req.body.displayNSFW !== undefined) user.displayNSFW = req.body.displayNSFW
|
||||
if (body.password) user.password = body.password
|
||||
if (body.displayNSFW !== undefined) user.displayNSFW = body.displayNSFW
|
||||
|
||||
return user.save()
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue