2014-01-26 23:26:01 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class CustomAuthExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
|
|
|
{
|
2021-02-10 16:50:20 +08:00
|
|
|
|
const
|
|
|
|
|
NAME = '',
|
|
|
|
|
CATEGORY = 'Login',
|
|
|
|
|
DESCRIPTION = '';
|
|
|
|
|
|
2020-08-31 00:04:54 +08:00
|
|
|
|
public function Init() : void
|
2014-01-26 23:26:01 +08:00
|
|
|
|
{
|
|
|
|
|
$this->addHook('filter.login-credentials', 'FilterLoginСredentials');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $sEmail
|
|
|
|
|
* @param string $sLogin
|
|
|
|
|
* @param string $sPassword
|
|
|
|
|
*
|
|
|
|
|
* @throws \RainLoop\Exceptions\ClientException
|
|
|
|
|
*/
|
|
|
|
|
public function FilterLoginСredentials(&$sEmail, &$sLogin, &$sPassword)
|
|
|
|
|
{
|
|
|
|
|
// Your custom php logic
|
|
|
|
|
// You may change login credentials
|
2020-10-15 22:21:52 +08:00
|
|
|
|
if ('demo@snappymail.eu' === $sEmail)
|
2014-01-26 23:26:01 +08:00
|
|
|
|
{
|
2020-10-15 22:21:52 +08:00
|
|
|
|
$sEmail = 'user@snappymail.eu';
|
|
|
|
|
$sLogin = 'user@snappymail.eu';
|
2014-01-26 23:26:01 +08:00
|
|
|
|
$sPassword = 'super-puper-password';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// or throw auth exeption
|
|
|
|
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
|
|
|
|
|
// or
|
|
|
|
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountNotAllowed);
|
|
|
|
|
// or
|
|
|
|
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DomainNotAllowed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|