Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485214
KeyCreateJob.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
KeyCreateJob.php
View Options
<?php
namespace
App\Jobs\PGP
;
use
App\Jobs\UserJob
;
/**
* 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
*
* @return void
*/
public
function
__construct
(
int
$userId
,
string
$userEmail
)
{
$this
->
userId
=
$userId
;
$this
->
userEmail
=
$userEmail
;
}
/**
* Execute the job.
*
* @return void
*
* @throws \Exception
*/
public
function
handle
()
{
$user
=
$this
->
getUser
();
if
(!
$user
)
{
return
;
}
// sanity checks
if
(
$user
->
isDeleted
())
{
$this
->
fail
(
new
\Exception
(
"User {$this->userId} is marked as deleted."
));
return
;
}
if
(
$user
->
trashed
())
{
$this
->
fail
(
new
\Exception
(
"User {$this->userId} is actually deleted."
));
return
;
}
if
(
$this
->
userEmail
!=
$user
->
email
&&
!
$user
->
aliases
()->
where
(
'alias'
,
$this
->
userEmail
)->
exists
()
)
{
$this
->
fail
(
new
\Exception
(
"Alias {$this->userEmail} is actually deleted."
));
return
;
}
\App\Backends\PGP
::
keypairCreate
(
$user
,
$this
->
userEmail
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 7:15 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387186
Default Alt Text
KeyCreateJob.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment