mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Custom Auth plugin example
This commit is contained in:
parent
38672e1672
commit
74991b16d9
3 changed files with 58 additions and 0 deletions
37
plugins/custom-auth-example/index.php
Normal file
37
plugins/custom-auth-example/index.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
class CustomAuthExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
public function Init()
|
||||
{
|
||||
$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
|
||||
if ('demo@rainloop.net' === $sEmail)
|
||||
{
|
||||
$sEmail = 'user@rainloop.net';
|
||||
$sLogin = 'user@rainloop.net';
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue