0

I have this weird problem. and I want a "yes" in all clients. I am using laravel 8 in client and API using laragon, with php 8.1.7 with apache 2.4.54


namespace App\Http\Controllers\Api\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use App\Http\Resources\UserResource;

class LoginController extends Controller
{
    public function store(Request $request)
    {
        $request->validate([
            'email' => 'required|string|email',
            'password' => 'required|string',
        ]);

        $user = User::where('email', 'xxxxxxx@gmail.com')->firstOrFail();

        return response()->json(['message' => (Hash::check('asd.4567', $user->password) ? 'yes': 'no')]);

        //it says yes, in thunder client, or php artisan tinker from the client page

        //it says no, from client page in web

        if (Hash::check($request->password, $user->password)) {
            return UserResource::make($user);
        } else {
            return response()->json(['message' => 'These credentials do not match our records.'], 404);
        }
    }
}

this is using apache, when I use nginx this part works, but no other thing that I need.

  • presumably in tinker or thunder client you are sending the password directly as it should be so there may be something in the password when it gets sent as a request. Do `dd($request->all())` in your controller to verify the password is being sent correctly – apokryfos Jul 24 '22 at 08:56
  • In this example I put the pass directly, and if y return the $request or the $user in both cases show the same thing, even if I change to nginx works fine in this part, but no in apache. – Leví Canales Jul 25 '22 at 16:12

0 Answers0