createaccount.cgi 1.44 KB
Newer Older
1
#!/usr/bin/perl -wT
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 10

use strict;

11
use lib qw(. lib);
12

13
use Bugzilla;
14
use Bugzilla::Constants;
15
use Bugzilla::Error;
16
use Bugzilla::Token;
17

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

26 27
print $cgi->header();

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

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

37
    $user->check_and_send_account_creation_confirmation($login);
38
    $vars->{'login'} = $login;
39

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

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