cesargb / laravel-magiclink

Create link for authenticate in Laravel without password or get private content
MIT License
359 stars 43 forks source link

Data too long for column 'action' at row 1 #58

Closed MCKLtech closed 2 years ago

MCKLtech commented 2 years ago

We've occasionally been hitting this error, and from the looks of the stack trace, it seems like a huge amount of information is being stored in the action column. It would appear the entire User model is being stuffed in there.

We're using the library in a wrapper function, where the $route could be a named route or a URL:

if (Route::has($route)) {
 $redirect = redirect(route($route));
} else $redirect = redirect($route);

return MagicLink::create(new LoginAction($user, $redirect), $lifetime,$maxVisits)
MCKLtech commented 2 years ago

Adding withoutRelations() seems to fix this issue. Perhaps, if relations are never needed, it would be advantageous for the package itself to implement this?

return MagicLink::create(
            new LoginAction(**$user->withoutRelations()**, $redirect),
            $lifetime,
            $maxVisits
        )
cesargb commented 2 years ago

Thanks for your feedback. In this issue we have 2 issues:

  1. too much user information stored
  2. wrapper method

Regarding the first problem, it would be interesting to store only the user's primary key.

I upload this PR #59