Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles with Session and non-API routes #1732

Open
celorodovalho opened this issue May 30, 2020 · 1 comment
Open

Troubles with Session and non-API routes #1732

celorodovalho opened this issue May 30, 2020 · 1 comment

Comments

@celorodovalho
Copy link

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 7.13.0
Package version 3.0
PHP version 7.4.6

Actual Behaviour

After install dingo/api, all my WEB actions (non-API) routes stop to flash messages:

    public function create()
    {
        //I can see the "success" index here
        dump(Session::all());
        return view('opportunities.create');
    }

    public function store(OpportunityCreateRequest $request): ?BaseResponse
    {
        return redirect()->back()->with(['success' => 'hello world!']);
    }
@section('content')
    {!! Form::open(['route' => 'opportunity.store', 'method' => 'post']) !!}
        @dump(session('success'))
        @dump(Session::all())

            {!! Form::label('title', 'Título da Vaga:', ['class' => 'col-lg-4 control-label']) !!}
            {!! Form::text('title', old('title'), ['class' => 'form-control' . ($errors->has('title') ? ' is-invalid' : ''), 'required' => true]) !!}

            {!! Form::submit('Enviar', ['class' => 'btn btn-lg btn-info pull-right'] ) !!}
    {!! Form::close() !!}
@endsection

The dump result inside the action "create"

array:3 [▼
  "_token" => "J0r94oAUhNTZo1F6Aica97s0Tly3muwxB7zscj2t"
  "_flash" => array:2 [▶]
  "success" => "hello world!"
]

The dump result inside the view "opportunity.create"

null
array:3 [▼
  "_token" => "J0r94oAUhNTZo1F6Aica97s0Tly3muwxB7zscj2t"
  "_flash" => array:2 [▶]
  "_previous" => array:1 [▶]
]

routes/web.php

Route::namespace('Web')
    ->group(static function () {
        Route::get('opportunity/create', 'OpportunityController@create')->name('opportunity.create');
        Route::post('opportunity', 'OpportunityController@store')->name('opportunity.store');
    });

Expected Behaviour

dingo/api should not change the Session and should not change the default behavior of flash messages, including "_old_input" data

@specialtactics
Copy link
Member

Hey @celorodovalho I think it shouldn't really do that, it probably depends on your middleware, session and other configs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants