This commit is contained in:
2024-09-09 21:51:40 +05:00
parent fc697f6318
commit bd992d87fb
7 changed files with 72 additions and 6 deletions

View File

@@ -9,6 +9,8 @@ use App\Modules\ApiAuth\Requests\AuthRegisterRequest;
use App\Modules\ApiAuth\Requests\AuthVerifyRequest;
use App\Repos\UserRepo;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\ValidationException;
class ApiAuthController extends Controller
{
@@ -31,6 +33,14 @@ class ApiAuthController extends Controller
*/
public function login(AuthLoginRequest $request): JsonResponse
{
$user = User::where('phone', $request->phone)->first();
if (! $user || ! Hash::check($request->password, $user->password)) {
throw ValidationException::withMessages([
'email' => ['The provided credentials are incorrect.'],
]);
}
sendSMSVerification($request->phone);
return response()->json([