Force URI (re)generation at TwoFAccount model saving

This commit is contained in:
Bubka 2020-11-14 18:43:30 +01:00
parent 0f53e6f93e
commit 657b9288da

View File

@ -71,6 +71,10 @@ protected static function boot()
static::retrieved(function ($model) { static::retrieved(function ($model) {
$model->populateFromUri(); $model->populateFromUri();
}); });
static::saving(function ($model) {
$model->refreshUri();
});
static::deleted(function ($model) { static::deleted(function ($model) {
Storage::delete('public/icons/' . $model->icon); Storage::delete('public/icons/' . $model->icon);
@ -334,9 +338,6 @@ public function populate(Array $attrib = [])
if (array_key_exists('imageLink', $attrib) && $attrib['imageLink']) if (array_key_exists('imageLink', $attrib) && $attrib['imageLink'])
{ $this->otp->setParameter( 'image', $attrib['imageLink'] ); } { $this->otp->setParameter( 'image', $attrib['imageLink'] ); }
// We can now generate a fresh URI
$this->uri = $this->otp->getProvisioningUri();
} }
catch (\Exception $e) { catch (\Exception $e) {
throw \Illuminate\Validation\ValidationException::withMessages([ throw \Illuminate\Validation\ValidationException::withMessages([