Encryption problem in Laravel

1

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){
    dd($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}', 'WorkerController@show');

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)') }}"
      class="dropdown-item">
         <i class="icon-head"></i> Editar Perfil
     </a>
 </div>

What kind of problem exists?

Greetings and thanks in advance.

    
asked by Peisou 06.08.2018 в 11:52
source

1 answer

2

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
source