- fix: Help is missing style

- fix: Setting expire password on user creation does nothing
 - fix: Collaboration settings in help
 - Lots of template fixes.
This commit is contained in:
JT Smith 2006-06-02 16:22:55 +00:00
parent 8d93d6bf2b
commit 771d11f833
12 changed files with 181 additions and 208 deletions

View file

@ -76,78 +76,6 @@ sub _isValidLDAPUser {
$self->error($error);
return $error eq "";
}
#-------------------------------------------------------------------
=head2 addUserForm ( )
Creates user form elements specific to this Auth Method.
=cut
sub addUserForm {
my $self = shift;
my $userData = $self->getParams;
my $connection = $self->{_connection};
my $ldapUrl = $self->session->form->process('authLDAP_ldapUrl') || $userData->{ldapUrl} || $connection->{ldapURL};
my $connectDN = $self->session->form->process('authLDAP_connectDN') || $userData->{connectDN};
my $ldapConnection = $self->session->form->process('authLDAP_ldapConnection') || $userData->{ldapConnection};
my $ldapLinks = $self->session->db->buildHashRef("select ldapLinkId,ldapUrl from ldapLink");
my $f = WebGUI::HTMLForm->new($self->session);
my $jscript = "";
my $i18n = WebGUI::International->new($self->session,'AuthLDAP');
if(scalar(keys %{$ldapLinks}) > 0) {
my $jsArray = "";
foreach my $key (keys %{$ldapLinks}) {
next unless ($key);
$jsArray .= 'ldapValue["'.$key.'"]="'.$ldapLinks->{$key}.'";'."\n";
}
$jsArray .= 'ldapValue["0"]="'.$ldapUrl.'";'."\n";
$jscript = qq|
<script type="text/javascript">
<!--
var ldapValue = new Array();
$jsArray
//-->
</script>|;
$f->selectBox(
-name=>"authLDAP_ldapConnection",
-label=>$i18n->get("ldapConnection"),
-hoverHelp=>$i18n->get("ldapConnection description"),
-options=>WebGUI::LDAPLink->getList($self->session,),
-value=>[$ldapConnection],
-extras=>q|onchange="this.form.authLDAP_ldapUrl.value=ldapValue[this.options[this.selectedIndex].value];"|
);
}
$f->url(
-name => "authLDAP_ldapUrl",
-label => $i18n->get(3),
-value => $ldapUrl,
);
$f->text(
-name => "authLDAP_connectDN",
-label => $i18n->get(4),
-value => $connectDN,
);
$self->session->style->setRawHeadTags($jscript);
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
=head2 addUserFormSave ( )
Saves user elements unique to this authentication method
=cut
sub addUserFormSave {
my $self = shift;
my $properties;
$properties->{connectDN} = $self->session->form->process('authLDAP_connectDN');
$properties->{ldapUrl} = $self->session->form->process('authLDAP_ldapUrl');
$properties->{ldapConnection} = $self->session->form->process('authLDAP_ldapConnection');
$self->SUPER::addUserFormSave($properties);
}
#-------------------------------------------------------------------
sub authenticate {
@ -335,7 +263,50 @@ sub displayLogin {
sub editUserForm {
my $self = shift;
return $self->addUserForm;
my $userData = $self->getParams;
my $connection = $self->{_connection};
my $ldapUrl = $self->session->form->process('authLDAP_ldapUrl') || $userData->{ldapUrl} || $connection->{ldapURL};
my $connectDN = $self->session->form->process('authLDAP_connectDN') || $userData->{connectDN};
my $ldapConnection = $self->session->form->process('authLDAP_ldapConnection') || $userData->{ldapConnection};
my $ldapLinks = $self->session->db->buildHashRef("select ldapLinkId,ldapUrl from ldapLink");
my $f = WebGUI::HTMLForm->new($self->session);
my $jscript = "";
my $i18n = WebGUI::International->new($self->session,'AuthLDAP');
if(scalar(keys %{$ldapLinks}) > 0) {
my $jsArray = "";
foreach my $key (keys %{$ldapLinks}) {
next unless ($key);
$jsArray .= 'ldapValue["'.$key.'"]="'.$ldapLinks->{$key}.'";'."\n";
}
$jsArray .= 'ldapValue["0"]="'.$ldapUrl.'";'."\n";
$jscript = qq|
<script type="text/javascript">
<!--
var ldapValue = new Array();
$jsArray
//-->
</script>|;
$f->selectBox(
-name=>"authLDAP_ldapConnection",
-label=>$i18n->get("ldapConnection"),
-hoverHelp=>$i18n->get("ldapConnection description"),
-options=>WebGUI::LDAPLink->getList($self->session,),
-value=>[$ldapConnection],
-extras=>q|onchange="this.form.authLDAP_ldapUrl.value=ldapValue[this.options[this.selectedIndex].value];"|
);
}
$f->url(
-name => "authLDAP_ldapUrl",
-label => $i18n->get(3),
-value => $ldapUrl,
);
$f->text(
-name => "authLDAP_connectDN",
-label => $i18n->get(4),
-value => $connectDN,
);
$self->session->style->setRawHeadTags($jscript);
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
@ -348,7 +319,11 @@ sub editUserForm {
sub editUserFormSave {
my $self = shift;
return $self->addUserFormSave;
my $properties;
$properties->{connectDN} = $self->session->form->process('authLDAP_connectDN');
$properties->{ldapUrl} = $self->session->form->process('authLDAP_ldapUrl');
$properties->{ldapConnection} = $self->session->form->process('authLDAP_ldapConnection');
$self->SUPER::editUserFormSave($properties);
}
#-------------------------------------------------------------------

View file

@ -70,75 +70,6 @@ sub _logSecurityMessage {
$self->session->errorHandler->security("change password. Password changed successfully");
}
#-------------------------------------------------------------------
=head2 addUserForm ( )
Creates user form elements specific to this Auth Method.
=cut
sub addUserForm {
my $self = shift;
my $userData = $self->getParams;
my $f = WebGUI::HTMLForm->new($self->session);
my $i18n = WebGUI::International->new($self->session);
$f->password(
name=>"authWebGUI.identifier",
label=>$i18n->get(51),
value=>"password"
);
$f->interval(
-name=>"authWebGUI.passwordTimeout",
-label=>$i18n->get(16,'AuthWebGUI'),
-value=>$userData->{passwordTimeout},
-defaultValue=>$self->session->setting->get("webguiPasswordTimeout")
);
my $userChange = $self->session->setting->get("webguiChangeUsername");
if($userChange || $userChange eq "0"){
$userChange = $userData->{changeUsername};
}
$f->yesNo(
-name=>"authWebGUI.changeUsername",
-value=>$userChange,
-label=>$i18n->get(21,'AuthWebGUI')
);
my $passwordChange = $self->session->setting->get("webguiChangePassword");
if($passwordChange || $passwordChange eq "0"){
$passwordChange = $userData->{changePassword};
}
$f->yesNo(
-name=>"authWebGUI.changePassword",
-value=>$passwordChange,
-label=>$i18n->get(20,'AuthWebGUI')
);
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
=head2 addUserFormSave ( )
Saves user elements unique to this authentication method
=cut
sub addUserFormSave {
my $self = shift;
my $properties;
unless ($self->session->form->process('authWebGUI.identifier') eq "password") {
$properties->{identifier} = Digest::MD5::md5_base64($self->session->form->process('authWebGUI.identifier'));
}
$properties->{changeUsername} = $self->session->form->process('authWebGUI.changeUsername');
$properties->{changePassword} = $self->session->form->process('authWebGUI.changePassword');
$properties->{passwordTimeout} = $self->session->form->interval('authWebGUI.passwordTimeout');
$properties->{passwordLastUpdated} =$self->session->datetime->time();
if($self->session->setting->get("webguiExpirePasswordOnCreation")){
$properties->{passwordLastUpdated} =$self->session->datetime->time() - $properties->{passwordTimeout};
}
$self->SUPER::addUserFormSave($properties);
}
#-------------------------------------------------------------------
sub authenticate {
my $self = shift;
@ -322,7 +253,39 @@ sub displayLogin {
sub editUserForm {
my $self = shift;
return $self->addUserForm;
my $userData = $self->getParams;
my $f = WebGUI::HTMLForm->new($self->session);
my $i18n = WebGUI::International->new($self->session);
$f->password(
name=>"authWebGUI.identifier",
label=>$i18n->get(51),
value=>"password"
);
$f->interval(
-name=>"authWebGUI.passwordTimeout",
-label=>$i18n->get(16,'AuthWebGUI'),
-value=>$userData->{passwordTimeout},
-defaultValue=>$self->session->setting->get("webguiPasswordTimeout")
);
my $userChange = $self->session->setting->get("webguiChangeUsername");
if($userChange || $userChange eq "0"){
$userChange = $userData->{changeUsername};
}
$f->yesNo(
-name=>"authWebGUI.changeUsername",
-value=>$userChange,
-label=>$i18n->get(21,'AuthWebGUI')
);
my $passwordChange = $self->session->setting->get("webguiChangePassword");
if($passwordChange || $passwordChange eq "0"){
$passwordChange = $userData->{changePassword};
}
$f->yesNo(
-name=>"authWebGUI.changePassword",
-value=>$passwordChange,
-label=>$i18n->get(20,'AuthWebGUI')
);
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
@ -347,6 +310,12 @@ sub editUserFormSave {
$properties->{passwordTimeout} = $self->session->form->interval('authWebGUI.passwordTimeout');
$properties->{changeUsername} = $self->session->form->process('authWebGUI.changeUsername');
$properties->{changePassword} = $self->session->form->process('authWebGUI.changePassword');
if($userId eq "new") {
$properties->{passwordLastUpdated} =$self->session->datetime->time();
if ($self->session->setting->get("webguiExpirePasswordOnCreation")){
$properties->{passwordLastUpdated} =$self->session->datetime->time() - $properties->{passwordTimeout};
}
}
$self->SUPER::editUserFormSave($properties);
}
@ -498,8 +467,9 @@ sub login {
if($self->getSetting("passwordTimeout") && $userData->{passwordTimeout}){
my $expireTime = $userData->{passwordLastUpdated} + $userData->{passwordTimeout};
if ($self->session->datetime->time() >= $expireTime){
my $userId = $self->userId;
$self->logout;
return $self->resetExpiredPassword($self->userId);
return $self->resetExpiredPassword($userId);
}
}
@ -619,19 +589,14 @@ sub resetExpiredPasswordSave {
$error .= '<li>'.$i18n->get(12,'AuthWebGUI').'</li>' if ($self->session->form->process("oldPassword") eq $self->session->form->process("identifier"));
$error .= $self->error if(!$self->_isValidPassword($self->session->form->process("identifier"),$self->session->form->process("identifierConfirm")));
return $self->resetExpiredPassword("<h1>".$i18n->get(70)."</h1>".$error) if($error ne "");
return $self->resetExpiredPassword($u->userId, "<h1>".$i18n->get(70)."</h1>".$error) if($error ne "");
$properties->{identifier} = Digest::MD5::md5_base64($self->session->form->process("identifier"));
$properties->{passwordLastUpdated} =$self->session->datetime->time();
$self->saveParams($u->userId,$self->authMethod,$properties);
$self->_logSecurityMessage();
$msg = $self->login;
if($msg eq ""){
$msg = "<li>".$i18n->get(17,'AuthWebGUI').'</li>';
}
return $self->displayLogin($msg);
return $self->SUPER::login();
}
#-------------------------------------------------------------------