mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 05:29:20 +03:00
Added more plugin hooks
Added proxy auth plugin example (dev)
This commit is contained in:
parent
819ba4a2ef
commit
9c43105e95
8 changed files with 432 additions and 123 deletions
20
plugins/proxyauth-login-example/LICENSE
Normal file
20
plugins/proxyauth-login-example/LICENSE
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 RainLoop Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
1
plugins/proxyauth-login-example/VERSION
Normal file
1
plugins/proxyauth-login-example/VERSION
Normal file
|
|
@ -0,0 +1 @@
|
|||
1.0
|
||||
41
plugins/proxyauth-login-example/index.php
Normal file
41
plugins/proxyauth-login-example/index.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
public function Init()
|
||||
{
|
||||
$this->addHook('event.login-post-login-provide', 'EventLoginPostLoginProvide');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
*/
|
||||
public function EventLoginPostLoginProvide(&$oAccount)
|
||||
{
|
||||
if ($oAccount instanceof \RainLoop\Account)
|
||||
{
|
||||
// Verify logic
|
||||
$bValid = 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
|
||||
*
|
||||
* @see \RainLoo\Account for more
|
||||
*/
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue