mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
Move ServiceRemoteAutoLogin to plugin/extension
This commit is contained in:
parent
9745d0ed89
commit
3079771f29
3 changed files with 71 additions and 27 deletions
51
plugins/login-remote/index.php
Normal file
51
plugins/login-remote/index.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
const
|
||||
NAME = 'Login Remote',
|
||||
AUTHOR = 'SnappyMail',
|
||||
URL = 'https://snappymail.eu/',
|
||||
VERSION = '1.0',
|
||||
RELEASE = '2022-11-11',
|
||||
REQUIRED = '2.21.0',
|
||||
CATEGORY = 'Login',
|
||||
LICENSE = 'MIT',
|
||||
DESCRIPTION = 'Tries to login using the $_ENV["REMOTE_*"] variables';
|
||||
|
||||
public function Init() : void
|
||||
{
|
||||
$this->addPartHook('RemoteAutoLogin', 'ServiceRemoteAutoLogin');
|
||||
}
|
||||
|
||||
public function ServiceRemoteAutoLogin() : bool
|
||||
{
|
||||
$oActions = \RainLoop\Api::Actions();
|
||||
|
||||
$oException = null;
|
||||
$oAccount = null;
|
||||
|
||||
$sEmail = $_ENV['REMOTE_USER'] ?? '';
|
||||
$sPassword = $_ENV['REMOTE_PASSWORD'] ?? '';
|
||||
|
||||
if (\strlen($sEmail) && \strlen($sPassword))
|
||||
{
|
||||
try
|
||||
{
|
||||
$oAccount = $oActions->LoginProcess($sEmail, $sPassword);
|
||||
if ($oAccount instanceof \RainLoop\Model\MainAccount) {
|
||||
$oActions->SetAuthToken($oAccount);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
$oLogger = $oActions->Logger();
|
||||
$oLogger && $oLogger->WriteException($oException);
|
||||
}
|
||||
}
|
||||
|
||||
$oActions->Location('./');
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue