fix login

This commit is contained in:
yotakii
2026-03-05 12:16:29 +03:00
parent 625bc26a05
commit 6d82c5007c
2 changed files with 133 additions and 177 deletions

View File

@@ -1,6 +1,6 @@
import { Request, Response } from 'express'
import { authService } from './auth.service'
import { AuthRequest } from '@/shared/middleware/auth'
import { AuthRequest } from '../../shared/middleware/auth'
export const authController = {
register: async (req: Request, res: Response) => {
@@ -21,7 +21,7 @@ export const authController = {
login: async (req: Request, res: Response) => {
try {
const { email, password } = req.body
if (!email || !password) {
@@ -31,7 +31,7 @@ export const authController = {
})
}
const result = await authService.login(email, password)
const result = await authService.login(String(email).trim(), String(password))
res.status(200).json({
success: true,
@@ -39,9 +39,9 @@ export const authController = {
data: result
})
} catch (error: any) {
res.status(401).json({
res.status(error?.statusCode || 401).json({
success: false,
message: error.message
message: error.message || 'بيانات الدخول غير صحيحة'
})
}
},