@@ -234,8 +234,11 @@ public function getMail(): string
234234 * @return bool true if key added, false if key not added because it was already there
235235 * @throws NoKeyLoadedException if key is invalid
236236 */
237- public function addSSHKey (string $ key , UnityUser $ operator , bool $ send_mail = true ): bool
238- {
237+ public function addSSHKey (
238+ string $ key ,
239+ ?UnityUser $ operator = null ,
240+ bool $ send_mail = true ,
241+ ): bool {
239242 if (in_array ($ key , $ this ->getSSHKeys ())) {
240243 return false ;
241244 }
@@ -244,7 +247,7 @@ public function addSSHKey(string $key, UnityUser $operator, bool $send_mail = tr
244247 return true ;
245248 }
246249
247- public function removeSSHKey (int $ index , UnityUser $ operator , bool $ send_mail = true )
250+ public function removeSSHKey (int $ index , ? UnityUser $ operator = null , bool $ send_mail = true )
248251 {
249252 $ keys = $ this ->getSSHKeys ();
250253 unset($ keys [$ index ]);
@@ -255,8 +258,12 @@ public function removeSSHKey(int $index, UnityUser $operator, bool $send_mail =
255258 /**
256259 * Sets the SSH keys on the account and the corresponding entry
257260 */
258- private function setSSHKeys (array $ keys , $ operator , bool $ send_mail = true ): void
259- {
261+ private function setSSHKeys (
262+ array $ keys ,
263+ ?UnityUser $ operator = null ,
264+ bool $ send_mail = true ,
265+ ): void {
266+ $ operator = is_null ($ operator ) ? $ this ->uid : $ operator ->uid ;
260267 \ensure ($ this ->entry ->exists ());
261268 $ this ->entry ->setAttribute ("sshpublickey " , $ keys );
262269 $ this ->entry ->write ();
0 commit comments