From 311c118834812685a35c473ffe07dd65f8972507 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Jul 2024 13:35:51 +0200 Subject: [PATCH] fix: Add newline character to private key before saving --- app/Models/PrivateKey.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index 187dfca58..880496344 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -14,6 +14,17 @@ class PrivateKey extends BaseModel 'team_id', ]; + protected static function booted() + { + static::saving(function ($key) { + $privateKey = data_get($key, 'private_key'); + if (substr($privateKey, -1) !== "\n") { + $key->private_key = $privateKey."\n"; + } + }); + + } + public static function ownedByCurrentTeam(array $select = ['*']) { $selectArray = collect($select)->concat(['id']);