thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.75k stars 2.67k forks source link

(Laravel Voyager) and (Vue SPA) Issue in route to (Admin) Panel after Login In #4721

Closed devhoussam closed 4 years ago

devhoussam commented 4 years ago

I have some issue in my Laravel Project I'm using Vue SPA and Laravel Voyager for Admin the problem is when I login to the Admin Panel it redirect me to home page (/) after login. I want to solve this problem please. This is my Routes/web.php

<?php

Route::group(['prefix' => 'admin'], function () {
    Voyager::routes();
});
Route::get('/{any}', 'CodeCommunityController@index')->where('any', '^(?!api).*$');
Route::get('/home', 'HomeController@index')->name('home');
Auth::routes();

This is Voyager Admin middleware

<?php

namespace TCG\Voyager\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class VoyagerAdminMiddleware 
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure                 $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        auth()->setDefaultDriver(app('VoyagerGuard'));

        if (!Auth::guest()) {
            $user = Auth::user();
            app()->setLocale($user->locale ?? app()->getLocale());

            return $user->hasPermission('browse_admin') ? $next($request) : redirect('/');
        }

        $urlLogin = route('voyager.login');

        return redirect()->guest($urlLogin);
    }
}
emptynick commented 4 years ago

The issue template is not optional when opening issues. Also questions should be asked in Slack.

devhoussam commented 4 years ago

ok my friend but if you can helping me the fix it please

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.