forked from RainLoop/rainloop-webmail
-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
607 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
integrations/nextcloud/snappymail/lib/Listeners/AccessTokenUpdatedListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\SnappyMail\Listeners; | ||
|
||
use OCA\OIDCLogin\Events\AccessTokenUpdatedEvent; | ||
use OCP\App\IAppManager; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\ISession; | ||
use OCP\IUserSession; | ||
|
||
class AccessTokenUpdatedListener implements IEventListener { | ||
private IUserSession $userSession; | ||
private ISession $session; | ||
private IAppManager $appManager; | ||
|
||
private const SNAPPYMAIL_APP_ID = 'snappymail'; | ||
private const OIDC_LOGIN_APP_ID = 'oidc_login'; | ||
|
||
|
||
public function __construct(IUserSession $userSession, ISession $session, IAppManager $appManager) { | ||
$this->userSession = $userSession; | ||
$this->session = $session; | ||
$this->appManager = $appManager; | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!($event instanceof AccessTokenUpdatedEvent) || !$this->userSession->isLoggedIn() || !$this->session->exists('is_oidc')) { | ||
return; | ||
} | ||
// just-in-case checks(also maybe useful for selfhosters) | ||
if (!$this->appManager->isEnabledForUser(self::SNAPPYMAIL_APP_ID) || !$this->appManager->isEnabledForUser(self::OIDC_LOGIN_APP_ID)) { | ||
return; | ||
} | ||
$accessToken = $event->getAccessToken(); | ||
if (!$accessToken) { | ||
return; | ||
} | ||
|
||
$username = $this->userSession->getUser()->getUID(); | ||
$this->session->set('snappymail-nc-uid', $username); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.