createaccount.cgi 1.48 KB
Newer Older
1
#!/usr/bin/perl -T
2 3 4
# 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/.
5
#
6 7
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
8

9
use 5.10.1;
10
use strict;
11 12
use warnings;

13
use lib qw(. lib);
14

15
use Bugzilla;
16
use Bugzilla::Constants;
17
use Bugzilla::Error;
18
use Bugzilla::Token;
19

20
# Just in case someone already has an account, let them get the correct footer
21
# on an error message. The user is logged out just after the account is
22
# actually created.
23
my $user = Bugzilla->login(LOGIN_OPTIONAL);
24
my $cgi = Bugzilla->cgi;
25
my $template = Bugzilla->template;
26
my $vars = { doc_section => 'using/creating-an-account.html' };
27

28 29
print $cgi->header();

30
$user->check_account_creation_enabled;
31
my $login = $cgi->param('login');
32 33

if (defined($login)) {
34 35 36 37 38
    # 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']);

39
    $user->check_and_send_account_creation_confirmation($login);
40
    $vars->{'login'} = $login;
41

42
    $template->process("account/created.html.tmpl", $vars)
43
      || ThrowTemplateError($template->error());
44 45 46
    exit;
}

47
# Show the standard "would you like to create an account?" form.
48 49
$template->process("account/create.html.tmpl", $vars)
  || ThrowTemplateError($template->error());