-
Notifications
You must be signed in to change notification settings - Fork 29
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
Laravel 5.5 - data is stored as decrypted after model update #22
Comments
Hey, I have the same problem did you found any solutions? |
Yes, you need to override public function getDirty()
{
$dirty = [];
foreach ($this->attributes as $key => $value) {
if (! $this->originalIsEquivalent($key, $value)) {
$dirty[$key] = $value;
}
}
return $dirty;
} |
Thanks 👍 |
Hrm, interesting. I wonder if it can be over-ridden in the trait and if doing so will cause breakages on prior versions of Laravel? I haven't started migrating any projects to L5.5 yet although it's a planned change with the new LTS release. I will keep this ticket open for monitoring and if anyone has any further information. |
IIRC Maybe we could just add second, optional trait with just Users of older Laravel versions wouldn't be affected by the changes. I can prepare pull request if you don't mind and if the change is ok for you. |
I just want to chime in that I am also looking to migrate from Laravel 5.1 to 5.5. I use this package to encrypt data in my database so I welcome any ideas on how to make it work on 5.5. |
There is also an other bug with Laravel 5.5: If an attribute is casted, the Our solution is to overwrite the /**
* Decrypt encrypted data before it is processed by cast attribute
* @param $key
* @param $value
*
* @return mixed
*/
protected function castAttribute($key, $value)
{
return parent::castAttribute($key, $this->doDecryptAttribute($key, $value));
} |
Thanks for the information. I'm continuing to track this. I'm about to migrate one project from 5.1 LTS to 5.5 LTS so I will try to build something that works for both LTS versions. |
Instead of trying to fix it for both versions at the same time (or forks or whatever), @delatbabel you could just release a new version which requires Laravel 5.5 |
@delatbabel any update on this? |
I ended up 1) forking this, 2) fixing all the Laravel 5.5 issues, 3) dropping support for Laravel below 5.5, and 4) a bunch of random cleanup & unit tests. Available below: |
@mrgrain where should one override the castAttribute method? |
@ITwrx Overwrite it in the model that needs to be encrypted. We have a base model for all encrypted models which uses Elocrypt's trait and overrides the Or you could simply create your own |
@mrgrain cool, thanks. |
Hi all, firstly sorry about the delay. I have had a long period of illness, just getting back to health now. I'll certainly look at integrating the patches into a Laravel 5.5 branch shortly. |
glad you're back. stay well. |
I have been testing this package for few days on Laravel 5.5. Recently, I've checked table content and some of the rows weren't encrypted at all.
After few tests in
artisan tinker
I've nailed the issue to updates that make the data unencrypted. Model creation works as expected.The problem happens also in default L5.5 installation, using MySQL (MariaDB 10.1.26 exactly):
composer create-project --prefer-dist laravel/laravel laravel55 cd laravel55 composer require delatbabel/elocryptfive php artisan make:auth php artisan migrate:fresh
app/User.php
:The value for
name
is encrypted.After the update table preview shows data as unecrypted.
The text was updated successfully, but these errors were encountered: