doujuxin7392 2018-04-12 20:39
浏览 63
已采纳

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

I want to have a context like this image:

enter image description here

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. After click Next, if is not authenticated he goes to the "login.blade.php" to login. After login he should be redirected to the 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".

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.

  • 写回答

1条回答 默认 最新

  • dongou3158 2018-04-12 21:07
    关注

    A. screen 1 should submit to a route protected by auth middleware.

    B. the route protected by auth middleware should return screen 3

    A-a. The auth middleware will take care of screen 2 and move them on to screen 3 when they are registered/logged in.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测