Page MenuHomePhorge

KeyCreateJob.php
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

KeyCreateJob.php

<?php
namespace App\Jobs\PGP;
use App\Jobs\UserJob;
use App\Support\Facades\PGP;
/**
* Create a GPG keypair for a user (or alias).
*
* Throws exceptions for the following reasons:
*
* * The user is marked as deleted (`$user->isDeleted()`), or
* * the user is actually deleted (`$user->deleted_at`)
* * the alias is actually deleted
* * there was an error in keypair generation process
*/
class KeyCreateJob extends UserJob
{
/**
* Create a new job instance.
*
* @param int $userId user identifier
* @param string $userEmail User email address for the key
*/
public function __construct(int $userId, string $userEmail)
{
$this->userId = $userId;
$this->userEmail = $userEmail;
}
/**
* Execute the job.
*
* @throws \Exception
*/
public function handle()
{
$user = $this->getUser();
if (!$user) {
return;
}
if ($user->trashed()) {
$this->fail("User {$user->email} is actually deleted.");
return;
}
if (
$this->userEmail != $user->email
&& !$user->aliases()->where('alias', $this->userEmail)->exists()
) {
$this->fail("Alias {$this->userEmail} is actually deleted.");
return;
}
PGP::keypairCreate($user, $this->userEmail);
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Apr 24, 10:51 AM (1 w, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18851772
Default Alt Text
KeyCreateJob.php (1 KB)

Event Timeline