lemonldap-ng/modules/lemonldap-ng-portal/example/mail.pl
Clément Oudot f6c250207c Portal - new feature: token to reset password by mail:
* A token is sent when user ask for password reset
* The token is linked to an apache session
* The password is reset if the token is valid
2010-01-21 17:38:55 +00:00

43 lines
1.1 KiB
Perl
Executable File

#!/usr/bin/perl
use Lemonldap::NG::Portal::MailReset;
use HTML::Template;
use strict;
my $skin_dir = "__SKINDIR__";
# Load portal module
my $portal = Lemonldap::NG::Portal::MailReset->new();
my $skin = $portal->{portalSkin};
my $portal_url = $portal->{portal};
# Process
$portal->process();
# Template creation
my $template = HTML::Template->new(
filename => "$skin_dir/$skin/mail.tpl",
die_on_bad_params => 0,
cache => 0,
filter => sub { $portal->translate_template(@_) }
);
$template->param( PORTAL_URL => "$portal_url" );
$template->param( SKIN => "$skin" );
$template->param( AUTH_ERROR => $portal->error );
$template->param( AUTH_ERROR_TYPE => $portal->error_type );
# Display form the first time
$template->param( DISPLAY_FORM => 1 )
if ( $portal->{error} == PE_MAILFORMEMPTY
or ( $portal->{error} == PE_BADCREDENTIALS and !$portal->{mail_token} ) );
# Display password if change is OK
$template->param( NEW_PASSWORD => $portal->{reset_password} )
if ( $portal->{error} == PE_PASSWORD_OK );
print $portal->header('text/html; charset=utf8');
print $template->output;