2003-03-27 03:07:02 +03:00
|
|
|
#!/usr/bin/perl -wT
|
1999-03-27 05:28:51 +03:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# 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.
|
|
|
|
#
|
1999-03-27 05:28:51 +03:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-02 02:33:56 +03:00
|
|
|
#
|
1999-03-27 05:28:51 +03:00
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
1999-03-27 05:28:51 +03:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
|
|
|
# David Gardiner <david.gardiner@unisa.edu.au>
|
2000-09-15 22:35:18 +04:00
|
|
|
# Joe Robins <jmrobins@tgix.com>
|
2001-09-23 21:20:50 +04:00
|
|
|
# Christopher Aillon <christopher@aillon.com>
|
2002-01-30 02:26:37 +03:00
|
|
|
# Gervase Markham <gerv@gerv.net>
|
1999-03-27 05:28:51 +03:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
use lib qw(.);
|
|
|
|
|
1999-03-27 05:28:51 +03:00
|
|
|
require "CGI.pl";
|
|
|
|
|
|
|
|
# Shut up misguided -w warnings about "used only once":
|
2002-02-13 05:27:24 +03:00
|
|
|
use vars qw(
|
|
|
|
%FORM
|
|
|
|
$template
|
|
|
|
$vars
|
|
|
|
);
|
1999-03-27 05:28:51 +03:00
|
|
|
|
2002-01-30 02:26:37 +03:00
|
|
|
ConnectToDatabase();
|
1999-03-27 05:28:51 +03:00
|
|
|
|
2000-09-15 22:35:18 +04:00
|
|
|
# If we're using LDAP for login, then we can't create a new account here.
|
2003-03-22 07:47:35 +03:00
|
|
|
unless (Bugzilla::Auth->can_edit) {
|
2002-06-17 13:39:00 +04:00
|
|
|
# Just in case someone already has an account, let them get the correct
|
|
|
|
# footer on the error message
|
|
|
|
quietly_check_login();
|
2003-03-22 07:47:35 +03:00
|
|
|
ThrowUserError("auth_cant_create_account");
|
2000-09-15 22:35:18 +04:00
|
|
|
}
|
1999-03-27 05:28:51 +03:00
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
|
|
|
|
2002-01-30 02:26:37 +03:00
|
|
|
# Clear out the login cookies. Make people log in again if they create an
|
|
|
|
# account; otherwise, they'll probably get confused.
|
2003-05-05 05:15:38 +04:00
|
|
|
$cgi->send_cookie(-name => 'Bugzilla_login',
|
|
|
|
-expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
|
|
|
|
$cgi->send_cookie(-name => 'Bugzilla_logincookie',
|
|
|
|
-expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
|
2002-01-30 02:26:37 +03:00
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
print $cgi->header();
|
2002-01-30 02:26:37 +03:00
|
|
|
|
1999-03-27 05:28:51 +03:00
|
|
|
my $login = $::FORM{'login'};
|
2002-01-30 02:26:37 +03:00
|
|
|
|
|
|
|
if (defined($login)) {
|
|
|
|
# We've been asked to create an account.
|
2002-07-11 23:24:29 +04:00
|
|
|
my $realname = trim($::FORM{'realname'});
|
1999-03-27 05:28:51 +03:00
|
|
|
CheckEmailSyntax($login);
|
2002-01-30 02:26:37 +03:00
|
|
|
$vars->{'login'} = $login;
|
|
|
|
|
2002-04-02 02:52:40 +04:00
|
|
|
if (!ValidateNewUser($login)) {
|
2002-01-30 02:26:37 +03:00
|
|
|
# Account already exists
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("account/exists.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2001-07-11 09:29:21 +04:00
|
|
|
exit;
|
1999-03-27 05:28:51 +03:00
|
|
|
}
|
2002-12-09 03:24:43 +03:00
|
|
|
|
|
|
|
my $createexp = Param('createemailregexp');
|
|
|
|
if (!($createexp)
|
|
|
|
|| ($login !~ /$createexp/)) {
|
|
|
|
ThrowUserError("account_creation_disabled");
|
|
|
|
exit;
|
|
|
|
}
|
2002-01-30 02:26:37 +03:00
|
|
|
|
|
|
|
# Create account
|
1999-08-19 04:06:01 +04:00
|
|
|
my $password = InsertNewUser($login, $realname);
|
1999-05-08 02:07:21 +04:00
|
|
|
MailPassword($login, $password);
|
2002-01-30 02:26:37 +03:00
|
|
|
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("account/created.html.tmpl", $vars)
|
2002-04-24 11:28:11 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
1999-03-27 05:28:51 +03:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2002-01-30 02:26:37 +03:00
|
|
|
# Show the standard "would you like to create an account?" form.
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("account/create.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|