简体   繁体   English

登录后在会话中存储什么内容以将用户重定向到注册页面?

[英]What is necessary to store in session to redirect the user to the registration page after login?

I want to have a context like this image: 我想要这样的上下文:

在此处输入图片说明

A unauthenticated user can access the congress details page single.blade.php and he can select the quantities that he want for each ticket type. 未经single.blade.php验证的用户可以访问大会详细信息页面single.blade.php并且可以为每种票证类型选择所需的数量。 After click Next , if is not authenticated he goes to the "login.blade.php" to login. 单击“ Next ,如果未通过身份验证,则转到“ login.blade.php”进行登录。 After login he should be redirected to the registration.blade.php . 登录后,他应该被重定向到registration.blade.php

So for the first screen I have this from action and route: 因此,对于第一个屏幕,我将从动作和路线中获得以下信息:

<form method="post" 
action="{{route('congresses.registration', 
['id' => $congress->id, 'slug' => $congress->slug])}}">


Route::get('/congress/{id}/{slug?}', [
    'uses' => 'FrontController@show',
    'as'   =>'congresses.show'
]);

For the user access the registration page he should be authenticated, so there is this route: 对于要访问注册页面的用户,应该对其进行身份验证,因此有以下路线:

Route::group(['prefix' => '', 'middleware' => 'auth'], function(){
        Route::post('/congress/{id}/{slug?}/registration', [
        'uses' => 'RegistrationController@storeQuantity',
        'as'   =>'congresses.registration'
    ]);
  }

Doubt: Do you know which data and what is necessary to store in session so is possible to redirect the user to the registration page after login? 疑问:您是否知道会话中需要存储哪些数据以及需要存储什么数据,以便可以在登录后将用户重定向到注册页面?

With the code I have for now without using sessions, the user select the quantities and click in "Next", then the user introduce the email and password click in "Confirm" and then the user is redirected to " http://layout.test/congress/1/congress-title-test/registration " but it appears always " Symfony \\ Component \\ HttpKernel \\ Exception \\ MethodNotAllowedHttpException ". 使用我现在没有使用会话的代码,用户选择数量并单击“下一步”,然后用户输入电子邮件和密码,然后单击“确认”,然后将用户重定向到“ http:// layout。 “ test / congress / 1 / congress-title-test / registration ”,但始终显示为“ Symfony \\ Component \\ HttpKernel \\ Exception \\ MethodNotAllowedHttpException ”。

LoginController: 的LoginController:

class LoginController extends Controller
{
    use AuthenticatesUsers;


    protected $redirectTo = '/';

    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    protected function authenticated(Request $request, $user)
    {
        return redirect()->intended($this->redirectTo);

    }
}

Routes: 路线:

Middleware group                                URI                                       NAME                            ACTION
    Get | Head | Web                            /                                          /                      App\Http\Controllers\FrontController@index

    Get | Head | Web                     congress/{id}/{slug?}                   congresses.show               App\Http\Controllers\FrontController@show

    Get | Head | POST | PUT 
    | PATCH | DELETE | 
    OPTIONS | WEB | AUTH             congress/{id}/{slug?}/registration     congresses.registration App\Http\Controllers\RegistrationController@storeQuantity

I also have the default laravel auth routes. 我也有默认的laravel auth路由。

A. screen 1 should submit to a route protected by auth middleware. A.屏幕1应该提交到受auth中间件保护的路由。

B. the route protected by auth middleware should return screen 3 B.受身份验证中间件保护的路由应返回屏幕3

Aa. AA级。 The auth middleware will take care of screen 2 and move them on to screen 3 when they are registered/logged in. auth中间件将负责屏幕2的注册,并在登录/登录后将其移至屏幕3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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