]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Resurrect createaccount.cgi (#68)
authorVladimir Panteleev <CyberShadow@users.noreply.github.com>
Mon, 15 Mar 2021 14:46:23 +0000 (14:46 +0000)
committerGitHub <noreply@github.com>
Mon, 15 Mar 2021 14:46:23 +0000 (15:46 +0100)
* Move the new sign-up mini-form to a template

* Resurrect createaccount.cgi

Many places in Bugzilla still link to createaccount.cgi. It is
probably worthwhile to still have a stand-alone sign-up page.

Simply reuse the mini-form to enable doing so using the new sign-up
flow.

* Make "Sign Up" link to createaccount.cgi

This fixes:

1. middle-clicking to open the form in a new tab
2. signing up without having to enable JavaScript
3. consistency with the "Log In" link, which already does something similar.

createaccount.cgi [new file with mode: 0644]
template/en/default/account/auth/signup-form.html.tmpl [new file with mode: 0644]
template/en/default/account/auth/signup-small.html.tmpl
template/en/default/account/create.html.tmpl

diff --git a/createaccount.cgi b/createaccount.cgi
new file mode 100644 (file)
index 0000000..f0fd407
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/env perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use 5.10.1;
+use strict;
+use warnings;
+
+use lib qw(. lib local/lib/perl5);
+
+use Bugzilla;
+use Bugzilla::Constants;
+use Bugzilla::Error;
+use Bugzilla::Token;
+
+# Just in case someone already has an account, let them get the correct footer
+# on an error message. The user is logged out just after the account is
+# actually created.
+my $user     = Bugzilla->login(LOGIN_OPTIONAL);
+my $cgi      = Bugzilla->cgi;
+my $template = Bugzilla->template;
+my $vars     = {doc_section => 'myaccount.html'};
+
+print $cgi->header();
+
+$user->check_account_creation_enabled;
+my $login = $cgi->param('login');
+
+if (defined($login)) {
+
+  # Check the hash token to make sure this user actually submitted
+  # the create account form.
+  my $token = $cgi->param('token');
+  check_hash_token($token, ['create_account']);
+
+  $user->check_and_send_account_creation_confirmation($login);
+  $vars->{'login'} = $login;
+
+  $template->process("account/created.html.tmpl", $vars)
+    || ThrowTemplateError($template->error());
+  exit;
+}
+
+# Show the standard "would you like to create an account?" form.
+$template->process("account/create.html.tmpl", $vars)
+  || ThrowTemplateError($template->error());
diff --git a/template/en/default/account/auth/signup-form.html.tmpl b/template/en/default/account/auth/signup-form.html.tmpl
new file mode 100644 (file)
index 0000000..591eae5
--- /dev/null
@@ -0,0 +1,42 @@
+[%# The contents of this file are subject to the Mozilla Public
+  # License Version 1.1 (the "License"); you may not use this file
+  # except in compliance with the License. You may obtain a copy of
+  # the License at http://www.mozilla.org/MPL/
+  #
+  # Software distributed under the License is distributed on an "AS
+  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+  # implied. See the License for the specific language governing
+  # rights and limitations under the License.
+  #
+  # The Original Code is the Bugzilla Bug Tracking System.
+  #
+  # The Initial Developer of the Original Code is Netscape Communications
+  # Corporation. Portions created by Netscape are
+  # Copyright (C) 1998 Netscape Communications Corporation. All
+  # Rights Reserved.
+  #
+  # Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
+  #%]
+
+  <form action="[% c.url_for('signup_email') FILTER html %]" method="post"
+        data-qs-suffix="[% qs_suffix FILTER html %]">
+
+    <input id="signup_email[% qs_suffix FILTER html %]"
+           class="bz_signup"
+           name="email"
+           title="Email"
+           placeholder="Email"
+           aria-label="Email"
+           type="email"
+           required
+    >
+    <input type="hidden" name="csrf_token"
+           value="[% c.csrf_token FILTER html %]">
+    <input type="submit" value="Sign up"
+           class="check_mini_signup_fields"
+            id="signup_[% qs_suffix FILTER html %]">
+    <a href="#" id="hide_mini_signup[% qs_suffix FILTER html %]" aria-label="Close"
+       class="close-button hide_mini_signup_form" data-qs-suffix="[% qs_suffix FILTER html %]">
+      <span class="icon" aria-hidden="true"></span>
+    </a>
+  </form>
index fba1cc191bcc13cb174d47639cbe5f09f104e945..ed5dfd4cbb991eff9162df0f0e9630ea1725e1e2 100644 (file)
   # then we are accessing the home page. %]
 
 <li id="mini_signup_container[% qs_suffix FILTER html %]">
-  <a id="signup_link[% qs_suffix FILTER html %]" href="#"
+  <a id="signup_link[% qs_suffix FILTER html %]" href="[% urlbase FILTER html %]createaccount.cgi"
      class='show_mini_signup_form' data-qs-suffix="[% qs_suffix FILTER html %]">Sign Up</a>
 
   <div id="mini_signup[% qs_suffix FILTER html %]" class="mini-popup mini_signup bz_default_hidden">
   [% Hook.process('additional_methods') %]
 
-  <form action="[% c.url_for('signup_email') FILTER html %]" method="post"
-        data-qs-suffix="[% qs_suffix FILTER html %]">
-
-    <input id="signup_email[% qs_suffix FILTER html %]"
-           class="bz_signup"
-           name="email"
-           title="Email"
-           placeholder="Email"
-           aria-label="Email"
-           type="email"
-           required
-    >
-    <input type="hidden" name="csrf_token"
-           value="[% c.csrf_token FILTER html %]">
-    <input type="submit" value="Sign up"
-           class="check_mini_signup_fields"
-            id="signup_[% qs_suffix FILTER html %]">
-    <a href="#" id="hide_mini_signup[% qs_suffix FILTER html %]" aria-label="Close"
-       class="close-button hide_mini_signup_form" data-qs-suffix="[% qs_suffix FILTER html %]">
-      <span class="icon" aria-hidden="true"></span>
-    </a>
-  </form>
+  [% PROCESS "account/auth/signup-form.html.tmpl" %]
   </div>
 </li>
index 93299f68246ff6f5f1d904175d51965ec96f320e..5ce75fab80d48d1ae89d33b0b1e7beeb904579b4 100644 (file)
 </p>
 [% END %]
 
-<form id="account_creation_form" method="get" action="[% basepath FILTER none %]createaccount.cgi">
-  <table>
-    <tr>
-      <td align="right">
-        <b>Email address:</b>
-      </td>
-      <td>
-        <input size="35" id="login" name="login"
-          [%- ' type="email"' UNLESS Param('emailsuffix') %]>
-        [% Param('emailsuffix') FILTER html %]
-      </td>
-    </tr>
-  </table>
-  <br>
-  <input type="hidden" id="token" name="token" value="[% issue_hash_token(['create_account']) FILTER html %]">
-  <input type="submit" id="send" value="Send">
-</form>
+[% PROCESS "account/auth/signup-form.html.tmpl" %]
 
 [% Hook.process('additional_methods') %]