From b57afa6438cd5512a1b35ba6ca3ec5e04e09de1e Mon Sep 17 00:00:00 2001 From: Amirmahdi Nourkazemi Date: Mon, 1 Sep 2025 20:33:51 +0330 Subject: [PATCH] fix: login and register --- app/Http/Controllers/UserController.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 2bb7d36..4f270b1 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -35,14 +35,14 @@ public function login(Request $request) } $user = User::where($authType, $data['auth'])->first(); - return response()->json([ - 'user' => $user, - // 'token' => $token, - 'hash'=> trim($data['password']), - 'password' => $user ? $user->password : null, - 'check' => $user ? Hash::check(trim($data['password']), $user->password) : null, + // return response()->json([ + // 'user' => $user, + // // 'token' => $token, + // 'hash'=> trim($data['password']), + // 'password' => $user ? $user->password : null, + // 'check' => $user ? Hash::check(trim($data['password']), $user->password) : null, - ]); + // ]); if (!$user || !Hash::check(trim($data['password']), $user->password)) { return response()->json(['message' => 'wrong credentials'], 404); } @@ -77,7 +77,7 @@ public function register(Request $request) return response()->json(['message' => 'Email already exists'], 400); } $pass = $data['password'] ?? null; - $data['password'] = isset($data['password']) ? Hash::make($data['password']) : Hash::make(config('app.default_password')); + $data['password'] = isset($data['password']) ? $data['password'] : Hash::make(Str::random(8)); $user = User::create($data); @@ -96,9 +96,6 @@ public function register(Request $request) return response()->json([ 'message' => 'User registered successfully.', 'user' => $user, - 'hash' => Hash::make($data['password']), - 'plain_password' => $pass, - 'check' => isset($pass) ? Hash::check($pass, $data['password']) : null, ]); }