diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index c6a775bb2..f05d7abbf 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.7.7 + - rfe #10061: Use email as username at registration 7.7.6 - Added mobile style template. If enabled in settings, will serve alternate style templates diff --git a/docs/upgrades/packages-7.7.7/default_webgui_anonymous_registration_template.wgpkg b/docs/upgrades/packages-7.7.7/default_webgui_anonymous_registration_template.wgpkg new file mode 100644 index 000000000..eff8e39cf Binary files /dev/null and b/docs/upgrades/packages-7.7.7/default_webgui_anonymous_registration_template.wgpkg differ diff --git a/docs/upgrades/upgrade_7.7.6-7.7.7.pl b/docs/upgrades/upgrade_7.7.6-7.7.7.pl index f060e12af..6196d9b4a 100644 --- a/docs/upgrades/upgrade_7.7.6-7.7.7.pl +++ b/docs/upgrades/upgrade_7.7.6-7.7.7.pl @@ -31,6 +31,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +addUseEmailAsUsernameToSettings( $session ); finish($session); # this line required @@ -44,6 +45,15 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- +sub addUseEmailAsUsernameToSettings { + my $session = shift; + print "\tAdding webguiUseEmailAsUsername to settings \n" unless $quiet; + + $session->db->write("insert into settings (name, value) values ('webguiUseEmailAsUsername',0)"); + print "Done.\n" unless $quiet; +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/lib/WebGUI/Auth/WebGUI.pm b/lib/WebGUI/Auth/WebGUI.pm index f8f0043c0..13e2935f3 100644 --- a/lib/WebGUI/Auth/WebGUI.pm +++ b/lib/WebGUI/Auth/WebGUI.pm @@ -163,14 +163,16 @@ sub createAccount { $vars->{'create.form.captcha.label'} = $i18n->get("captcha label","AuthWebGUI"); } - my $username = $form->process("authWebGUI.username"); - $vars->{'create.form.username'} - = WebGUI::Form::text($self->session, { - name => "authWebGUI.username", - value => $username, - extras => $self->getExtrasStyle($username) - }); - $vars->{'create.form.username.label'} = $i18n->get(50); + unless($setting->get('webguiUseEmailAsUsername')){ + my $username = $form->process("authWebGUI.username"); + $vars->{'create.form.username'} + = WebGUI::Form::text($self->session, { + name => "authWebGUI.username", + value => $username, + extras => $self->getExtrasStyle($username) + }); + $vars->{'create.form.username.label'} = $i18n->get(50); + } my $password = $form->process("authWebGUI.identifier"); $vars->{'create.form.password'} @@ -217,7 +219,13 @@ sub createAccountSave { $session->errorHandler->security($i18n->get("no registration hack", "AuthWebGUI")); return $self->displayLogin; } - my $username = $form->process('authWebGUI.username'); + my $username; + if($setting->get('webguiUseEmailAsUsername')){ + $username = $form->process('email'); + } + else{ + $username = $form->process('authWebGUI.username'); + } my $password = $form->process('authWebGUI.identifier'); my $passConfirm = $form->process('authWebGUI.identifierConfirm'); @@ -503,6 +511,12 @@ sub editUserSettingsForm { -label => $i18n->get(869,'WebGUI'), -hoverHelp => $i18n->get('869 help','WebGUI'), ); + $f->yesNo( + -name => "webguiUseEmailAsUsername", + -value => $self->session->setting->get("webguiUseEmailAsUsername"), + -label => $i18n->get('use email as username label'), + -hoverHelp => $i18n->get('use email as username description'), + ); $f->yesNo( -name => "webguiChangeUsername", -value => $self->session->setting->get("webguiChangeUsername"), @@ -611,6 +625,7 @@ sub editUserSettingsFormSave { $s->set("webguiWelcomeMessage", $f->process("webguiWelcomeMessage","textarea")); $s->set("webguiChangeUsername", $f->process("webguiChangeUsername","yesNo")); $s->set("webguiChangePassword", $f->process("webguiChangePassword","yesNo")); + $s->set("webguiUseEmailAsUsername", $f->process("webguiUseEmailAsUsername")); # Make sure we have the ability to recover a password if we're trying to # enable password recovery diff --git a/lib/WebGUI/i18n/English/AuthWebGUI.pm b/lib/WebGUI/i18n/English/AuthWebGUI.pm index e15756d17..d3618d565 100644 --- a/lib/WebGUI/i18n/English/AuthWebGUI.pm +++ b/lib/WebGUI/i18n/English/AuthWebGUI.pm @@ -796,6 +796,17 @@ Settings screen, displayed as hoverhelp.|, context => q|Description of the newUser_password tmpl_var for the template help.|, }, + 'use email as username label' => { + message => 'Use Email Address as Username', + lastUpdated => 0, + context => q|Label of the webguiUseEmailAsUsername field on the Auth tab of the Edit Settings screen.|, + }, + + 'use email as username description' => { + message => 'When this is set to Yes, the registration screen will not show a username field. Instead the submitted email address will automatically be used as username.', + lastUpdated => 0, + context => q|Description of the webguiUseEmailAsUsername field, used as hoverhelp on the Auth tab of the Edit Settings screen.|, + }, }; 1;