Online demo Privacy policy

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.

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:

$config['CUSTOM_EMAIL_QUERY_FUNCTION'] = 'my_custom_func';

function my_custom_func($username = '') {
   $session = Registry::get('session');
   $data = $session->get("auth_data");

   $a = array();

   foreach($data['emails'] as $email) {
      $s = explode("@", $email);
      array_push($a, $s[0] . "@otherdomain.com");
   }

   $data['emails'] = array_merge($data['emails'] , $a);

   $session->set("auth_data", $data);
}

If you want to change some aspects of the gui before the authentication takes place, then write a similar function. The following example would allow logins from a certain domain only, and reject others:

$config['CUSTOM_EMAIL_QUERY_FUNCTION'] = 'iii';

function iii($username = '') {
   global $session;

   if(!strstr($username, "@domain.com")) {
      $session->set("auth_data", array());
   }
}
Google Analytics Alternative