refactor: move security to route by route
This commit is contained in:
parent
123210c2dd
commit
d0d59cea0d
1 changed files with 6 additions and 1 deletions
|
|
@ -121,9 +121,9 @@ function imageLocation(id: string) {
|
||||||
|
|
||||||
@Route("api/v1/user")
|
@Route("api/v1/user")
|
||||||
@Tags("User")
|
@Tags("User")
|
||||||
@Security("keycloak")
|
|
||||||
export class UserController extends Controller {
|
export class UserController extends Controller {
|
||||||
@Get("type-stats")
|
@Get("type-stats")
|
||||||
|
@Security("keycloak")
|
||||||
async getUserTypeStats() {
|
async getUserTypeStats() {
|
||||||
const list = await prisma.user.groupBy({
|
const list = await prisma.user.groupBy({
|
||||||
by: "userType",
|
by: "userType",
|
||||||
|
|
@ -145,6 +145,7 @@ export class UserController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@Security("keycloak")
|
||||||
async getUser(
|
async getUser(
|
||||||
@Query() userType?: UserType,
|
@Query() userType?: UserType,
|
||||||
@Query() zipCode?: string,
|
@Query() zipCode?: string,
|
||||||
|
|
@ -199,6 +200,7 @@ export class UserController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{userId}")
|
@Get("{userId}")
|
||||||
|
@Security("keycloak")
|
||||||
async getUserById(@Path() userId: string) {
|
async getUserById(@Path() userId: string) {
|
||||||
const record = await prisma.user.findFirst({
|
const record = await prisma.user.findFirst({
|
||||||
include: {
|
include: {
|
||||||
|
|
@ -221,6 +223,7 @@ export class UserController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@Security("keycloak")
|
||||||
async createUser(@Request() req: RequestWithUser, @Body() body: UserCreate) {
|
async createUser(@Request() req: RequestWithUser, @Body() body: UserCreate) {
|
||||||
if (body.provinceId || body.districtId || body.subDistrictId) {
|
if (body.provinceId || body.districtId || body.subDistrictId) {
|
||||||
const [province, district, subDistrict] = await prisma.$transaction([
|
const [province, district, subDistrict] = await prisma.$transaction([
|
||||||
|
|
@ -316,6 +319,7 @@ export class UserController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put("{userId}")
|
@Put("{userId}")
|
||||||
|
@Security("keycloak")
|
||||||
async editUser(
|
async editUser(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: UserUpdate,
|
@Body() body: UserUpdate,
|
||||||
|
|
@ -454,6 +458,7 @@ export class UserController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{userId}")
|
@Delete("{userId}")
|
||||||
|
@Security("keycloak")
|
||||||
async deleteUser(@Path() userId: string) {
|
async deleteUser(@Path() userId: string) {
|
||||||
const record = await prisma.user.findFirst({
|
const record = await prisma.user.findFirst({
|
||||||
include: {
|
include: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue