Fixes potential for accidental update/deletion of edited model
This commit is contained in:
parent
65a91baa16
commit
71e6d2e1b6
1 changed files with 11 additions and 3 deletions
|
@ -122,13 +122,21 @@ class Server extends Model
|
||||||
|
|
||||||
$result = $query->first();
|
$result = $query->first();
|
||||||
|
|
||||||
// @TODO: saving after calling this could end up resetting the daemon secret.
|
|
||||||
// We probably need to just allow access to self::getUserDaemonSecret() to
|
|
||||||
// get this result.
|
|
||||||
if(!is_null($result)) {
|
if(!is_null($result)) {
|
||||||
$result->daemonSecret = self::getUserDaemonSecret($result);
|
$result->daemonSecret = self::getUserDaemonSecret($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent saving of model called in this manner.
|
||||||
|
// Prevents accidental overwrite of main daemon secret.
|
||||||
|
$result::saving(function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prevent deleting this model call.
|
||||||
|
$result::deleting(function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
self::$serverUUIDInstance[$uuid] = $result;
|
self::$serverUUIDInstance[$uuid] = $result;
|
||||||
return self::$serverUUIDInstance[$uuid];
|
return self::$serverUUIDInstance[$uuid];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue