Hey everyone,
I got a bit of a confusing situation here.
I have a password that is stored in the database and automatically encrypted through the casts() method.
protected function casts(): array
{
return [
'password' => 'encrypted',
];
}
This works like i expect it to. Now i use this password in a service where it is used in an API Request for Basic Auth there i access it like this:
$response = Http::acceptJson()
->withoutVerifying()
->withQueryParameters($parameters)
->withHeaders($this->basicAuthHeader($credentials->username, $credentials->password))
->get("$this->base_url/do");
This seems to work as $credentials->password is automatically decrypted when i access it.
Now my problem is that this behavior is inconsistent. I allow the user to update that password through a Livewire Form but for some unknown reason when i access the value there it stays encrypted.
class CredentialsForm extends Form
{
public ?Credentials $credentials;
#[Validate('required|min:3')]
public $username;
#[Validate('required|min:3')]
public $password;
public function setCredentials(Credentials $credentials): void
{
$this->credentials = $credentials;
$this->username = $this->credentials->username;
$this->password = $this->credentials->password;
}
}
Now i assume laravel-magic somehow knows this is "possibly dangerous" so it doesn't decrypt the value but how can i control what it does. I didn't find anything in the docs for this.
So maybe somebody else can explain this to me. Why it is not decrypting the value in the Livewire form but in my service class ?
Thanks in advance ^^