Roles section
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Response } from 'express';
|
||||
import { AuthenticatedRequest } from '../middleware/auth.middleware';
|
||||
import { AuthenticatedRequest } from '../types';
|
||||
import * as roleService from '../services/role.service';
|
||||
import { CreateRoleInput, UpdateRoleInput } from '../validators/role.validator';
|
||||
|
||||
@@ -37,9 +37,10 @@ export async function getRoleById(
|
||||
res: Response
|
||||
): Promise<void> {
|
||||
try {
|
||||
const roleId = parseInt(req.params.id, 10);
|
||||
const roleId = req.params.id;
|
||||
|
||||
if (isNaN(roleId)) {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(roleId)) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: 'Invalid role ID',
|
||||
@@ -120,9 +121,10 @@ export async function updateRole(
|
||||
res: Response
|
||||
): Promise<void> {
|
||||
try {
|
||||
const roleId = parseInt(req.params.id, 10);
|
||||
const roleId = req.params.id;
|
||||
|
||||
if (isNaN(roleId)) {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(roleId)) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: 'Invalid role ID',
|
||||
@@ -178,9 +180,10 @@ export async function deleteRole(
|
||||
res: Response
|
||||
): Promise<void> {
|
||||
try {
|
||||
const roleId = parseInt(req.params.id, 10);
|
||||
const roleId = req.params.id;
|
||||
|
||||
if (isNaN(roleId)) {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(roleId)) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: 'Invalid role ID',
|
||||
|
||||
Reference in New Issue
Block a user