validate([ 'email' => 'required|email', 'password' => 'required|string', ]); $user = IamPrincipal::where('email_address', $validatedData['email'])->first(); if ($user) { if (Hash::check($validatedData['password'], $user->password)) { // Log in the user explicitly Auth::guard('admin')->login($user); return jsonResponseWithSuccessMessage(__('success.authentic_success'), 200); } else { return jsonResponseWithErrorMessage(__('auth.password'), 401); } } else { return jsonResponseWithErrorMessage(__('auth.email'), 401); } } }