bug #2757: change the opac login generation
This patch change the method used to generate a new login for a user when his informations are modified(memberentry.pl). Before the login are generated with the first letter of lastname and the 9 first letter of the surname, and do not verify the login already exist). Now the login will be lastname.surnameX, where X is an incremented digit if the login already exists. Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
parent
41db97255c
commit
873d1c6336
2 changed files with 26 additions and 14 deletions
|
@ -97,15 +97,16 @@ BEGIN {
|
|||
);
|
||||
|
||||
#Check data
|
||||
push @EXPORT, qw(
|
||||
&checkuniquemember
|
||||
&checkuserpassword
|
||||
&Check_Userid
|
||||
&fixEthnicity
|
||||
ðnicitycategories
|
||||
&fixup_cardnumber
|
||||
&checkcardnumber
|
||||
);
|
||||
push @EXPORT, qw(
|
||||
&checkuniquemember
|
||||
&checkuserpassword
|
||||
&Check_Userid
|
||||
&Generate_Userid
|
||||
&fixEthnicity
|
||||
ðnicitycategories
|
||||
&fixup_cardnumber
|
||||
&checkcardnumber
|
||||
);
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
@ -799,6 +800,21 @@ sub Check_Userid {
|
|||
}
|
||||
}
|
||||
|
||||
sub Generate_Userid {
|
||||
my ($borrowernumber, $firstname, $surname) = @_;
|
||||
my $newuid;
|
||||
my $offset = 0;
|
||||
do {
|
||||
$firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
|
||||
$surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
|
||||
$newuid = lc("$firstname.$surname");
|
||||
$newuid .= $offset unless $offset == 0;
|
||||
$offset++;
|
||||
|
||||
} while (!Check_Userid($newuid,$borrowernumber));
|
||||
|
||||
return $newuid;
|
||||
}
|
||||
|
||||
sub changepassword {
|
||||
my ( $uid, $member, $digest ) = @_;
|
||||
|
|
|
@ -181,13 +181,10 @@ if ($guarantorid eq '') {
|
|||
|
||||
#builds default userid
|
||||
if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){
|
||||
my $onefirstnameletter = substr($data{'firstname'},0,1);
|
||||
my $fivesurnameletter = substr($data{'surname'} ,0,9);
|
||||
$newdata{'userid'}=lc($onefirstnameletter.$fivesurnameletter);
|
||||
$newdata{'userid'} = Generate_Userid($borrowernumber, $newdata{'firstname'}, $newdata{'surname'});
|
||||
}
|
||||
|
||||
$debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
|
||||
my $loginexist = 0;
|
||||
my $extended_patron_attributes = ();
|
||||
if ($op eq 'save' || $op eq 'insert'){
|
||||
if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){
|
||||
|
@ -214,7 +211,6 @@ if ($op eq 'save' || $op eq 'insert'){
|
|||
# Check if the userid is unique
|
||||
unless (Check_Userid($newdata{'userid'},$borrowernumber)) {
|
||||
push @errors, "ERROR_login_exist";
|
||||
$loginexist=1;
|
||||
}
|
||||
|
||||
my $password = $input->param('password');
|
||||
|
|
Loading…
Reference in a new issue