Encryption problem in Laravel


I want to make a new view in my laravel application, so that the logged in user can edit their profile, my problem comes when I get the error of:

DecryptException in compiled.php line 13235:
The payload is invalid.

I have debugged the method to see that it returns the request when it calls the route to invoke the new view and has the following output:


.Crypt :: encrypt (Auth :: user () - > id)

This is method:

public function show($id){
    try {
        $decrypted_id = \Crypt::decrypt($id);
    } catch (DecryptException $e) {
        return redirect('/home');
    $worker = Worker::find($decrypted_id);
    return view('worker.show')->with('worker',$worker);

the route:

Route::get('/worker/show/{id_worker}', '[email protected]');

and the piece of code from the main view that leads to the edit profile menu:

 <div class="dropdown-menu dropdown-menu-right">
     <a href="{{ url('/worker/show/.Crypt::encrypt(Auth::user()->id)') }}"
         <i class="icon-head"></i> Editar Perfil

What kind of problem exists?

Greetings and thanks in advance.

asked by Peisou 06.08.2018 в 11:52

1 answer


I think the problem is caused by the concatenation of the value.

Review the following line:

 <a href="{{ url('/worker/show/.Crypt::encrypt(Auth::user()->id)') }}" ... >

Change it to this one:

 <a href="{{ url('/worker/show/' . Crypt::encrypt(Auth::user()->id)) }}" ... >
answered by 06.08.2018 / 15:36