snappymail/plugins/proxyauth-login-example/index.php

51 lines
1.2 KiB
PHP
Raw Normal View History

<?php
class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
{
public function Init()
{
$this->addHook('event.login-post-login-provide', 'EventLoginPostLoginProvide');
}
/**
2014-11-15 04:23:46 +08:00
* @param string $sLogin
* @param string $sPassword
*/
public function isValidAccount($sLogin, $sPassword)
{
return !empty($sLogin) && !empty($sPassword);
}
/**
* @param \RainLoop\Model\Account $oAccount
*/
public function EventLoginPostLoginProvide(&$oAccount)
{
2014-11-15 04:23:46 +08:00
if ($oAccount instanceof \RainLoop\Model\Account)
{
// Verify logic
2015-02-01 23:44:44 +08:00
$bValid = $this->isValidAccount($oAccount->Login(), $oAccount->Password());
/**
* $oAccount->Email(); // Email (It is not a IMAP login)
* $oAccount->Login(); // IMAP login
* $oAccount->Password(); // IMAP password
* $oAccount->DomainIncHost(); // IMAP host
*
2014-11-15 04:23:46 +08:00
* @see \RainLoo\Model\Account for more
*/
2014-11-15 04:23:46 +08:00
if (!$bValid) // if verify failed
{
// throw a Auth Error Exception
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
else // Or setup your proxyauth admin account credentials
{
$oAccount->SetProxyAuthUser('admin@domain.com');
$oAccount->SetProxyAuthPassword('secret-admin-password');
}
}
}
}