update profile and password

This commit is contained in:
2024-11-27 17:20:17 +07:00
parent 98b6bf4cd6
commit 7b712d9ee9
3 changed files with 7 additions and 17 deletions

View File

@ -1,4 +1,5 @@
import { Request, Response, NextFunction, Application } from "express"; import { Response, NextFunction, Application } from "express";
import { Request } from "express-jwt";
import { ReturnHelper } from "../helpers/express/return"; import { ReturnHelper } from "../helpers/express/return";
import { OrmHelper } from "../helpers/orm"; import { OrmHelper } from "../helpers/orm";
import { User } from "../entity/users"; import { User } from "../entity/users";
@ -161,12 +162,6 @@ export class UserController {
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['id'] = {
in: 'path',
description: 'User ID.',
required: true,
type: 'string'
}
#swagger.requestBody = { #swagger.requestBody = {
required: true, required: true,
@ -188,7 +183,7 @@ export class UserController {
name: Joi.string().max(64).required().label('Name'), name: Joi.string().max(64).required().label('Name'),
}); });
req.body.id = req.params['id']; req.body.id = req.auth.data.id;
const param: User = await schema.validateAsync(req.body); const param: User = await schema.validateAsync(req.body);
@ -221,12 +216,6 @@ export class UserController {
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['id'] = {
in: 'path',
description: 'User ID.',
required: true,
type: 'string'
}
#swagger.requestBody = { #swagger.requestBody = {
required: true, required: true,
@ -247,7 +236,7 @@ export class UserController {
retype_password: Joi.ref('password'), retype_password: Joi.ref('password'),
}); });
req.body.id = req.params['id']; req.body.id = req.auth.data.id;
const param: User = await schema.validateAsync(req.body); const param: User = await schema.validateAsync(req.body);

View File

@ -16,8 +16,8 @@ export class RoutePrivate {
app.get('/api/user/list', UserController.list) app.get('/api/user/list', UserController.list)
app.post('/api/user/create', UserController.create) app.post('/api/user/create', UserController.create)
app.put('/api/user/update/:id', UserController.update) app.put('/api/user/update/:id', UserController.update)
app.put('/api/user/update_profile/:id', UserController.updateProfile) app.put('/api/user/update_profile', UserController.updateProfile)
app.put('/api/user/update_password/:id', UserController.updatePassword) app.put('/api/user/update_password', UserController.updatePassword)
app.delete('/api/user/delete/:id', UserController.delete) app.delete('/api/user/delete/:id', UserController.delete)
app.put('/api/user/restore/:id', UserController.restore) app.put('/api/user/restore/:id', UserController.restore)

View File

@ -6,6 +6,7 @@ export class RoutePublic {
static setup(app: express.Application) { static setup(app: express.Application) {
app.post('/api/login', AuthController.login) app.post('/api/login', AuthController.login)
app.post('/api/reset_password', AuthController.login)
app.put('/api/logout/:refresh_token', AuthController.logout) app.put('/api/logout/:refresh_token', AuthController.logout)
app.put('/api/renew_token/:refresh_token', AuthController.renewToken) app.put('/api/renew_token/:refresh_token', AuthController.renewToken)