diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 838d43f84..191008a1d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -68,6 +68,7 @@ - rfe: VIM perl mode for skeletons - rfe: Add edit button to Manage Revisions page - rfe: Protected profile fields don't show delete icon + - rfe: Registration form to keep user entries on error - required and errored fields are now highlighted. 7.5.22 - fixed: Layout template now gets prepared correctly diff --git a/docs/upgrades/packages-7.6.0/default_ldap_anonymous_registration_template.wgpkg b/docs/upgrades/packages-7.6.0/default_ldap_anonymous_registration_template.wgpkg new file mode 100644 index 000000000..bf891a3c6 Binary files /dev/null and b/docs/upgrades/packages-7.6.0/default_ldap_anonymous_registration_template.wgpkg differ diff --git a/docs/upgrades/packages-7.6.0/default_webgui_anonymous_registration_template.wgpkg b/docs/upgrades/packages-7.6.0/default_webgui_anonymous_registration_template.wgpkg new file mode 100644 index 000000000..1c9bc595d Binary files /dev/null and b/docs/upgrades/packages-7.6.0/default_webgui_anonymous_registration_template.wgpkg differ diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 03324959a..0b8cf4fd6 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -187,8 +187,8 @@ sub createAccount { my $i18n = WebGUI::International->new($self->session); $vars->{title} = $i18n->get(54); - $vars->{'create.form.header'} - = WebGUI::Form::formHeader($self->session,{}) + $vars->{'create.form.header'} + = WebGUI::Form::formHeader($self->session) . WebGUI::Form::hidden($self->session,{"name"=>"op","value"=>"auth"}) . WebGUI::Form::hidden($self->session,{"name"=>"method","value"=>$method}) ; @@ -197,11 +197,18 @@ sub createAccount { my $userInvitation = $self->session->setting->get('userInvitationsEnabled'); $vars->{'create.form.profile'} = []; foreach my $field (@{WebGUI::ProfileField->getRegistrationFields($self->session)}) { - my $id = $field->getId; - my $label = $field->getLabel; + my $id = $field->getId; + my $label = $field->getLabel; + my $required = $field->isRequired; - # Get the default email from the invitation + my $properties = {}; + if ($required) { + my $fieldValue = $self->session->form->process($field->getId,$field->get("fieldType")); + $properties->{extras} = $self->getExtrasStyle($fieldValue); + } + my $formField; + # Get the default email from the invitation if ($field->get('fieldName') eq "email" && $userInvitation ) { my $code = $self->session->form->get('code') || $self->session->form->get('uniqueUserInvitationCode'); @@ -211,12 +218,12 @@ sub createAccount { [$code] ); $vars->{'create.form.header'} .= WebGUI::Form::hidden($self->session, {name=>"uniqueUserInvitationCode", value=>$code}); - $formField = $field->formField(undef, undef, undef, undef, $defaultValue); + $formField = $field->formField($properties, undef, undef, undef, $defaultValue); } else { - $formField = $field->formField(); + $formField = $field->formField($properties); } - my $required = $field->isRequired; + # Old-style field loop. push @{$vars->{'create.form.profile'}}, { @@ -615,7 +622,28 @@ sub getCreateAccountTemplateId { #------------------------------------------------------------------- -=head2 getAccountTemplateId ( ) +=head2 getExtrasStyle ( ) + +This method returns the proper field to display for required fields. + +=cut + +sub getExtrasStyle { + my $self = shift; + my $value = shift; + + my $requiredStyleOff = q{class="authfield_required_off"}; + my $requiredStyle = q{class="authfield_required"}; + my $errorStyle = q{class="authfield_error"}; #Required Field Not Filled In and Error Returend + + return $errorStyle if($self->error && $value eq ""); + return $requiredStyle unless($value); + return $requiredStyleOff; +} + +#------------------------------------------------------------------- + +=head2 getLoginTemplateId ( ) This method should be overridden by the subclass and should return the template ID for the login screen. diff --git a/lib/WebGUI/Auth/LDAP.pm b/lib/WebGUI/Auth/LDAP.pm index 9c77b4cb8..1142d9ad3 100644 --- a/lib/WebGUI/Auth/LDAP.pm +++ b/lib/WebGUI/Auth/LDAP.pm @@ -241,13 +241,24 @@ sub createAccount { value=>[$connection->{ldapLinkId}], extras=>qq|onchange="location.href='$url'+this.options[this.selectedIndex].value"| }); - $vars->{'create.form.ldapId'} = WebGUI::Form::text($self->session,{"name"=>"authLDAP_ldapId","value"=>$self->session->form->process("authLDAP_ldapId")}); - $vars->{'create.form.ldapId.label'} = $connection->{ldapIdentityName}; - $vars->{'create.form.password'} = WebGUI::Form::password($self->session,{"name"=>"authLDAP_identifier","value"=>$self->session->form->process("authLDAP_identifier")}); - $vars->{'create.form.password.label'} = $connection->{ldapPasswordName}; + my $ldapId = $self->session->form->process("authLDAP_ldapId"); + $vars->{'create.form.ldapId'} = WebGUI::Form::text($self->session,{ + name =>"authLDAP_ldapId", + value =>$ldapId, + extras => $self->getExtrasStyle($ldapId) + }); + $vars->{'create.form.ldapId.label'} = $connection->{ldapIdentityName}; + + my $ldapPwd = $self->session->form->process("authLDAP_identifier"); + $vars->{'create.form.password'} = WebGUI::Form::password($self->session,{ + "name"=>"authLDAP_identifier", + "value"=> $ldapPwd, + extras => $self->getExtrasStyle($ldapPwd) + }); + $vars->{'create.form.password.label'} = $connection->{ldapPasswordName}; - $vars->{'create.form.hidden'} = WebGUI::Form::hidden($self->session,{"name"=>"confirm","value"=>$confirm}); - return $self->SUPER::createAccount("createAccountSave",$vars); + $vars->{'create.form.hidden'} = WebGUI::Form::hidden($self->session,{"name"=>"confirm","value"=>$confirm}); + return $self->SUPER::createAccount("createAccountSave",$vars); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Auth/WebGUI.pm b/lib/WebGUI/Auth/WebGUI.pm index 0e5ecd025..64c586da1 100644 --- a/lib/WebGUI/Auth/WebGUI.pm +++ b/lib/WebGUI/Auth/WebGUI.pm @@ -131,43 +131,63 @@ sub authenticate { #------------------------------------------------------------------- sub createAccount { my $self = shift; + my $session = $self->session; + my $form = $session->form; + my $setting = $session->setting; + my $message = shift; - my $confirm = shift || $self->session->form->process("confirm"); - my $vars = shift || {}; + my $confirm = shift || $form->process("confirm"); + my $vars = shift || {}; + my $i18n = WebGUI::International->new($session); - #$self->session->errorHandler->warn('WebGUI::Auth::createAccount called'); if ($self->session->user->isRegistered) { return $self->displayAccount; } - elsif (!$self->session->setting->get("anonymousRegistration") && !$self->session->setting->get('userInvitationsEnabled')) { + elsif (!$setting->get("anonymousRegistration") && !$setting->get('userInvitationsEnabled')) { return $self->displayLogin; } - my $i18n = WebGUI::International->new($self->session); + $vars->{'create.message'} = '' if ($message); - $vars->{useCaptcha} = $self->session->setting->get("webguiUseCaptcha"); + $vars->{'useCaptcha' } = $setting->get("webguiUseCaptcha"); + if ($vars->{useCaptcha}) { use WebGUI::Form::Captcha; - my $captcha = WebGUI::Form::Captcha->new($self->session,{"name"=>"authWebGUI.captcha"}); + my $captcha = WebGUI::Form::Captcha->new($session,{ + name => "authWebGUI.captcha", + extras => $self->getExtrasStyle + }); $vars->{'create.form.captcha'} = $captcha->toHtml . '' . $captcha->get('subtext').''; $vars->{'create.form.captcha.label'} = $i18n->get("captcha label","AuthWebGUI"); } - $vars->{'create.form.username'} + + my $username = $form->process("authWebGUI.username"); + $vars->{'create.form.username'} = WebGUI::Form::text($self->session, { - "name" => "authWebGUI.username", - "value" => $self->session->form->process("authWebGUI.username"), + name => "authWebGUI.username", + value => $username, + extras => $self->getExtrasStyle($username) }); $vars->{'create.form.username.label'} = $i18n->get(50); - $vars->{'create.form.password'} + + my $password = $form->process("authWebGUI.identifier"); + $vars->{'create.form.password'} = WebGUI::Form::password($self->session, { - "name" => "authWebGUI.identifier" + name => "authWebGUI.identifier", + value => $password, + extras => $self->getExtrasStyle($password) }); $vars->{'create.form.password.label'} = $i18n->get(51); + + my $passwordConfirm = $form->process("authWebGUI.identifierConfirm"); $vars->{'create.form.passwordConfirm'} = WebGUI::Form::password($self->session, { - "name" => "authWebGUI.identifierConfirm" + name => "authWebGUI.identifierConfirm", + value => $passwordConfirm, + extras => $self->getExtrasStyle($passwordConfirm) }); $vars->{'create.form.passwordConfirm.label'} = $i18n->get(2,'AuthWebGUI'); + $vars->{'create.form.hidden'} = WebGUI::Form::hidden($self->session, { "name" => "confirm", @@ -211,7 +231,10 @@ sub createAccountSave { my ($profile, $temp, $warning) = WebGUI::Operation::Profile::validateProfileData($self->session, {regOnly => 1}); $error .= $temp; - return $self->createAccount($error) unless ($error eq ""); + unless ($error eq "") { + $self->error($error); + return $self->createAccount($error); + } # If Email address is not unique, a warning is displayed if ($warning ne "" && !$self->session->form->process("confirm")) {