Ad
Login Page Redirect To Blank Page Afer Authentication In Laravel 6
my login page redirect me to blank page with url:http://127.0.0.1:8000/login
instead of the dashboard.
this is my loginController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
use App\Http\Requests\LoginRequest;
class LoginController extends Controller
{
public function show()
{
return view('auth/login');
}
public function authenticate(LoginRequest $requestFields)
{
$attributes = $requestFields->only(['username', 'password']);
if (Auth::attempt($attributes)) {
return redirect()->route('dashboard');
}
}
public function logout()
{
Session::flush();
Auth::logout();
return back();
}
}
loginRequest class
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; // Set this to "true" else Unauthorized error will be thrown
}
public function rules()
{
return [
'username' => ['required', 'string'],
'password' => ['required', 'string', 'min:8'],
];
}
}
web.php
// Register & Login User
Route::post('/login', '[email protected]');
Route::post('/register', '[email protected]');
// Protected Routes - allows only logged in users
Route::middleware('auth')->group(function () {
Route::get('/dashboard', '[email protected]')->name('dashboard');
Route::post('/logout', '[email protected]');
});
I expected redirect to dashboard page after login using the username and password,I tried changing the route in RedirectIfAuthenticated.php but it did not work.
Ad
Answer
the issue was I didn't hash my password properly in the registerController hence I couldn't authenticate user that log in.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad