mirror of
https://github.com/elyby/accounts.git
synced 2026-04-26 01:02:55 +05:30
Implemented oauth session revocation notification.
Reworked webhooks notifications constructors
This commit is contained in:
30
common/notifications/OAuthSessionRevokedNotification.php
Normal file
30
common/notifications/OAuthSessionRevokedNotification.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\notifications;
|
||||
|
||||
use common\models\OauthSession;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class OAuthSessionRevokedNotification implements NotificationInterface {
|
||||
|
||||
private OauthSession $oauthSession;
|
||||
|
||||
public function __construct(OauthSession $oauthSession) {
|
||||
Assert::notNull($oauthSession->revoked_at, 'OAuth session must be revoked');
|
||||
$this->oauthSession = $oauthSession;
|
||||
}
|
||||
|
||||
public static function getType(): string {
|
||||
return 'oauth2.session_revoked';
|
||||
}
|
||||
|
||||
public function getPayloads(): array {
|
||||
return [
|
||||
'accountId' => $this->oauthSession->account_id,
|
||||
'clientId' => $this->oauthSession->client_id,
|
||||
'revoked' => date('c', $this->oauthSession->revoked_at),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user