Differences

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

Link to this comparison view

Next revision
Previous revision
documentation:2.1:plugincustom [2019/01/15 15:55]
127.0.0.1 external edit
documentation:2.1:plugincustom [2019/05/02 15:12]
coudot [Presentation]
Line 11: Line 11:
   * ''​forAuthUser'':​ method called for already authenticated users   * ''​forAuthUser'':​ method called for already authenticated users
   * ''​beforeLogout'':​ method called before logout   * ''​beforeLogout'':​ method called before logout
 +
 +If you need to call a method just after any standard method in authentication process, then use ''​afterSub'',​ for example:
 +<code perl>
 +  use constant afterSub => {
 +      getUser => '​mysub',​
 +  }
 +  sub mysub {
 +      my ( $self ,$req ) = @_;
 +      # Do something
 +      return PE_OK;
 +  }
 +</​code>​
 +
 +If you need to call a method instead any standard method in authentication process, then use ''​aroundSub'',​ for example:
 +<code perl>
 +  use constant aroundSub => {
 +      getUser => '​mysub',​
 +  };
 +  sub mysub {
 +      my ( $self, $sub, $req ) = @_;
 +      # Do something before
 +      my $ret = $sub->​($req);​
 +      # Do something after
 +      return $ret;
 +  }
 +</​code>​
  
 The plugin can also define new routes and call actions on them. The plugin can also define new routes and call actions on them.
Line 24: Line 50:
 vi /​usr/​share/​perl5/​Lemonldap/​NG/​Portal/​MyPlugin.pm vi /​usr/​share/​perl5/​Lemonldap/​NG/​Portal/​MyPlugin.pm
 </​code>​ </​code>​
 +<note tip>If you do not want to mix files from the distribution with your own work, put your own code in ''/​usr/​local/​lib/​site_perl/​Lemonldap/​NG/​Portal/​MyPlugin.pm''</​note>​
 <file perl> <file perl>
 package Lemonldap::​NG::​Portal::​MyPlugin;​ package Lemonldap::​NG::​Portal::​MyPlugin;​