2012-02-05 13:25:55 +01:00
|
|
|
|
##@file
|
|
|
|
|
# Demo password backend file
|
|
|
|
|
|
|
|
|
|
##@class
|
|
|
|
|
# Demo password backend class
|
|
|
|
|
package Lemonldap::NG::Portal::PasswordDBDemo;
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
use Lemonldap::NG::Portal::Simple;
|
|
|
|
|
|
2012-10-15 06:12:21 +02:00
|
|
|
|
our $VERSION = '1.2.2';
|
2012-02-05 13:25:55 +01:00
|
|
|
|
|
|
|
|
|
## @apmethod int passwordDBInit()
|
|
|
|
|
# Check the use of AuthDemo
|
|
|
|
|
# @return Lemonldap::NG::Portal constant
|
|
|
|
|
sub passwordDBInit {
|
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
|
|
if ( $self->get_module('auth') eq 'Demo' ) {
|
|
|
|
|
return PE_OK;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$self->lmLog( "Use PasswordDBDemo only with AuthDemo", 'error' );
|
|
|
|
|
return PE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PE_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
## @apmethod int modifyPassword()
|
|
|
|
|
# Check old password and password mismatch
|
|
|
|
|
# @return Lemonldap::NG::Portal constant
|
|
|
|
|
sub modifyPassword {
|
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
|
|
# Exit if no password change requested
|
|
|
|
|
return PE_OK unless ( $self->{newpassword} );
|
2012-09-08 12:55:55 +02:00
|
|
|
|
|
2012-08-31 15:00:06 +02:00
|
|
|
|
# Check if portal require old password
|
|
|
|
|
if ( $self->{portalRequireOldPassword} ) {
|
|
|
|
|
unless ( $self->{oldpassword} ) {
|
2012-09-08 12:55:55 +02:00
|
|
|
|
$self->lmLog( "Portal require old password", 'error' );
|
2012-10-15 06:12:21 +02:00
|
|
|
|
return PE_PP_MUST_SUPPLY_OLD_PASSWORD;
|
2012-08-31 15:00:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-05 13:25:55 +01:00
|
|
|
|
|
|
|
|
|
# Verify confirmation password matching
|
|
|
|
|
return PE_PASSWORD_MISMATCH
|
|
|
|
|
unless ( $self->{newpassword} eq $self->{confirmpassword} );
|
|
|
|
|
|
|
|
|
|
# Check old password
|
|
|
|
|
if ( $self->{oldpassword} ) {
|
|
|
|
|
|
|
|
|
|
# Old password must be the same as uid
|
|
|
|
|
return PE_BADOLDPASSWORD
|
|
|
|
|
if ( $self->{oldpassword} ne $self->{sessionInfo}->{uid} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Else accept all passwords
|
|
|
|
|
# They will not be changed
|
|
|
|
|
PE_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
1;
|