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

Nothing happended #3

Open
Kingmaddi opened this issue Dec 30, 2018 · 1 comment
Open

Nothing happended #3

Kingmaddi opened this issue Dec 30, 2018 · 1 comment

Comments

@Kingmaddi
Copy link

Hi,

thank you for this plugin.
I have a problem with saving encrypted data.
Then i save my model, the normal unencrypted data saved to the database.
What´s my mistake? I declare the encryption key in the env-file like you describe it in your introduction.

Thank you for help

@RGlintmeijer
Copy link

Same issue here on a new Laravel project (5.7.19). It does work when you update your model with a new value.

This seems to be caused by the different handling in the performInsert and performUpdate functions in Illuminate\Database\Eloquent\Model.

The performInsert function uses Model->getAttributes(), which returns the unencrypted values.
The performUpdate function uses Model->getDirty(), which returns the encrypted values.

Example:

$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> $account=new App\testaccount();
=> App\testaccount {#3005}
>>> $account->username='user1'
=> "user1"
>>> $account->password1='test'
=> "test"
>>> $account->getAttributes();
=> [
     "username" => "user1",
     "password1" => "test",
   ]
>>> $account->getDirty();
=> [
     "username" => "user1",
     "password1" => "__AESCRYPT__:lkoFwYJFVGm3CLjhuKxVqQ==",
   ]
>>>

Currently i've removed the (overridden) function getAttributes() from Aescrypt.php, but i don't know if this has any impact on other things.

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