Online demo Privacy policy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
current:custom-authentication [2016/03/08 21:49]
sj
current:custom-authentication [2019/10/31 21:16] (current)
sj
Line 1: Line 1:
 ==== Custom authentication ==== ==== Custom authentication ====
  
-Piler from version 1.2.0 (including the master branch) ​allows you to alter or fix the authentication,​ eg. add extra email addresses, etc. You may think about it as a post authentication hook.+Piler allows you to alter or fix the authentication,​ eg. add extra email addresses, etc. You may think about it as a post authentication hook.
  
 The following example adds a 2nd domain name to your email addresses. Let's say you have two addresses user@domain.com,​ and alias@domain.com,​ and you want to read emails for user@otherdomain.com,​ and alias@otherdomain.com. Then add the following to config-site.php:​ The following example adds a 2nd domain name to your email addresses. Let's say you have two addresses user@domain.com,​ and alias@domain.com,​ and you want to read emails for user@otherdomain.com,​ and alias@otherdomain.com. Then add the following to config-site.php:​
Line 40: Line 40:
 </​code>​ </​code>​
  
 +
 +Piler also supports a pre authentication hook which runs before any authentication is performed.
 +
 +Look at the below example. You define only IMAP_PORT and IMAP_SSL in config-site.php,​ and set the IMAP_SERVER based on the domain part of the username:
 +
 +<​code>​
 +$config['​CUSTOM_PRE_AUTH_FUNCTION'​] = '​my_imap';​
 +
 +function my_imap($username = ''​) {
 +   ​global $session;
 +
 +   ​if(strstr($username,​ "​@domain1.com"​)) {
 +      define('​IMAP_SERVER',​ '​imap.domain1.com'​);​
 +   } else if(strstr($username,​ "​@domain2.com"​)) {
 +      define('​IMAP_SERVER',​ '​imap.domain2.com'​);​
 +   } else {
 +      define('​IMAP_SERVER',​ '​imap.somedomain.com'​);​
 +   }
 +}
 +</​code>​
  
Google Analytics Alternative