fix: correct req.user property from id to userId in controllers
This commit is contained in:
@@ -89,7 +89,7 @@ export async function getById(req: Request, res: Response): Promise<void> {
|
||||
*/
|
||||
export async function create(req: AuthenticatedRequest, res: Response): Promise<void> {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
const userId = req.user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
res.status(401).json({
|
||||
|
||||
@@ -81,7 +81,7 @@ export async function getById(req: Request, res: Response): Promise<void> {
|
||||
*/
|
||||
export async function create(req: AuthenticatedRequest, res: Response): Promise<void> {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
const userId = req.user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
res.status(401).json({
|
||||
|
||||
@@ -254,7 +254,7 @@ export async function deleteUser(
|
||||
}
|
||||
|
||||
// Prevent admin from deleting themselves
|
||||
if (req.user?.id === userId) {
|
||||
if (req.user?.userId === userId) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: 'Cannot deactivate your own account',
|
||||
@@ -305,7 +305,7 @@ export async function changePassword(
|
||||
}
|
||||
|
||||
// Only allow users to change their own password
|
||||
if (req.user?.id !== userId) {
|
||||
if (req.user?.userId !== userId) {
|
||||
res.status(403).json({
|
||||
success: false,
|
||||
error: 'You can only change your own password',
|
||||
|
||||
Reference in New Issue
Block a user