简体   繁体   中英

always redirect to root path after authentication [laravel]

After authentication, it always redirect to root path. I'd like to make it routes to auth/register_draw . Could you tell me how to route it?

AuthController.php

public function postRegister(Request $request)
{
    $validator = $this->validator($request->all());
    if ($validator->fails()) {
        $this->throwValidationException(
                $request, $validator
        );
    }
    $user = $this->create($request->all());
    Auth::guard($this->getGuard())->login($user);
    Mail::send(
        'auth.emails.register',
        ['user' => $user],
            function (Message $message) use ($user) {
                $message->sender(\Config::get('const.mail.register.from'), \Config::get('const.mail.register.name'))
                        ->to($user->email)
                        ->subject(\Config::get('const.mail.register.subject'));
            }
    );

    return redirect()->route('register_draw');
    // return redirect()->route('auth/register_draw');
}

routes.php

Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

Route::get('auth/register_draw', 'Auth\AuthController@getRegisterDraw')->name('register_draw');

Try this:

return redirect()->route('auth.register_draw');

Also, make sure you have this route:

Route::get('auth/register_draw', Controller@method);

Or something similar.

You can check all available rouotes with php artisan route:list command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM