fix login
This commit is contained in:
@@ -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 || 'بيانات الدخول غير صحيحة'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user