Cannot enter the dashboard page when logging in

70 Views Asked by At

I have a problem where when the user tries to log in, and when they want to click the login button they are not directed to the dashboard page.i use fortify in my laravel

this is the html form

type her<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Login</title>

    <link rel="stylesheet" href="{{ asset('assets/css/login/global.css') }}">
    <link rel="stylesheet" href="{{ asset('assets/css/login/index.css') }}">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" />
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>

<body>
    <div class="login">
        <img class="logo" alt="" src="{{ asset('assets/img/login/logo.png') }}">
        <div class="banner-parent">
            <form method="post" action="{{ route('login') }}" class="needs-validation" novalidate="">
                @csrf
                <div class="banner">
                    <div class="banner1">
                        <b class="daftar-akun">Login</b>
                    </div>
                </div>
                <div class="frame-wrapper">
                    <div class="inputs-parent">
                        <div class="inputs">
                            <div class="statedefault">
                                <div class="col-md-12">
                                    <label for="email" class="form-label">Email address</label>
                                    <input type="email"
                                        class="form-control @error('email')
                  is-invalid
                  @enderror"
                                        id="email" name="email" aria-describedby="email">
                                    @error('email')
                                        <div class="invalid-feedback" style="text-align: center;">
                                            {{ $message }}
                                        </div>
                                    @enderror
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="inputs1">
                        <div class="statedefault">
                            <div class="col-md-12">
                                <label for="password" class="form-label">Password</label>
                                <input type="password"
                                    class="form-control @error('password') 
                  is-invalid
                @enderror"
                                    id="password" name="password">
                                @error('password')
                                    <div class="invalid-feedback" style="text-align: center;">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>
                    </div>
                </div>
                <div class="lupa-password-parent">
                    <a href="" class="lupa-password" style="text-decoration: none; color:black">Lupa Password ?</a>
                    <button type="submit" class="btn btn-info" style="color: white">Login</button>
                </div>
            </form>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous">
    </script>
</body>

</html>

in my RouteServiceProvider.php there is no change

<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * The path to your application's "home" route.
     *
     * Typically, users are redirected here after authentication.
     *
     * @var string
     */
    public const HOME = '/home';

    /**
     * Define your route model bindings, pattern filters, and other route configuration.
     */
    public function boot(): void
    {
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
        });

        $this->routes(function () {
            Route::middleware('api')
                ->prefix('api')
                ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->group(base_path('routes/web.php'));
        });
    }
}

and in the web.php file here I grouped the routes. However, when I don't group the route, the dashboard page can be opened. but the user cannot log in

<?php

use App\Http\Controllers\BerandaAdminController;
use App\Http\Controllers\BerandaController;
use App\Http\Controllers\DatadiriUserController;
use App\Http\Controllers\DataOrangTuaController;
use App\Http\Controllers\DataOrangTuaUserController;
use App\Http\Controllers\DataPesertaDidikController;
use App\Http\Controllers\DetailDataOrangTuaController;
use App\Http\Controllers\DetailDataPesertaDidikController;
use App\Http\Controllers\DetailPembayaranController;
use App\Http\Controllers\GantiPasswordController;
use App\Http\Controllers\LandingPageController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\PembayaranAdminController;
use App\Http\Controllers\PembayaranController;
use App\Http\Controllers\RegisterController;
use App\Http\Controllers\TesAdminController;
use App\Http\Controllers\TesController;
use App\Http\Controllers\UploadAdminController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\UploadDetailController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

// Route semua user
Route::get('/', function () {
    return view('layouts.landingpage', [LandingPageController::class, 'index']);
})->name('landingpage');

Route::get('/login', function () {
    return view(('auth.login'));
})->name('login');

Route::middleware(['auth'])->group(function () {
    Route::get('home', function () {
        return view('user.dashboard');
    })->name('home');
});

Please help, it's been almost 3 days now and I don't know where the error is

I've tried changing RouteServiceProvider.php from home to dashboard but that didn't work

1

There are 1 best solutions below

0
Bilal Saad On

To resolve this issue you need add route for POST Method to get Login Information and redirect it to dashboard.

Route::post('/login', function () {
   // your code to authenticate user
});