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(.);
|
|
|
|
|
2005-08-10 05:30:41 +04:00
|
|
|
require "globals.pl";
|
1999-03-27 05:28:51 +03:00
|
|
|
|
2005-07-28 00:15:37 +04:00
|
|
|
use Bugzilla;
|
2005-05-19 23:35:48 +04:00
|
|
|
use Bugzilla::Constants;
|
2005-02-09 09:42:43 +03:00
|
|
|
use Bugzilla::User;
|
2005-07-11 04:40:59 +04:00
|
|
|
use Bugzilla::BugMail;
|
2005-07-21 01:24:19 +04:00
|
|
|
use Bugzilla::Util;
|
2005-02-01 00:04:12 +03:00
|
|
|
|
2005-03-30 13:57:29 +04:00
|
|
|
# Just in case someone already has an account, let them get the correct footer
|
2005-07-28 00:15:37 +04:00
|
|
|
# on an error message. The user is logged out just after the account is
|
2005-03-30 13:57:29 +04:00
|
|
|
# actually created.
|
2005-05-19 23:35:48 +04:00
|
|
|
Bugzilla->login(LOGIN_OPTIONAL);
|
2005-03-30 13:57:29 +04:00
|
|
|
|
2005-07-28 00:15:37 +04:00
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-10-25 03:11:56 +04:00
|
|
|
my $template = Bugzilla->template;
|
|
|
|
my $vars = {};
|
|
|
|
|
2005-07-28 00:15:37 +04:00
|
|
|
print $cgi->header();
|
|
|
|
|
2000-09-15 22:35:18 +04:00
|
|
|
# If we're using LDAP for login, then we can't create a new account here.
|
2006-05-12 06:41:22 +04:00
|
|
|
unless (Bugzilla->user->authorizer->user_can_create_account) {
|
2005-03-30 13:57:29 +04:00
|
|
|
ThrowUserError("auth_cant_create_account");
|
2000-09-15 22:35:18 +04:00
|
|
|
}
|
1999-03-27 05:28:51 +03:00
|
|
|
|
2005-03-30 13:57:29 +04:00
|
|
|
my $createexp = Param('createemailregexp');
|
|
|
|
unless ($createexp) {
|
|
|
|
ThrowUserError("account_creation_disabled");
|
|
|
|
}
|
2002-01-30 02:26:37 +03:00
|
|
|
|
2004-02-24 15:25:11 +03:00
|
|
|
my $login = $cgi->param('login');
|
2002-01-30 02:26:37 +03:00
|
|
|
|
|
|
|
if (defined($login)) {
|
|
|
|
# We've been asked to create an account.
|
2004-02-24 15:25:11 +03:00
|
|
|
my $realname = trim($cgi->param('realname'));
|
2005-08-15 21:43:38 +04:00
|
|
|
|
|
|
|
validate_email_syntax($login)
|
|
|
|
|| ThrowUserError('illegal_email_address', {addr => $login});
|
|
|
|
|
2002-01-30 02:26:37 +03:00
|
|
|
$vars->{'login'} = $login;
|
2005-07-28 00:15:37 +04:00
|
|
|
|
2006-06-08 00:31:10 +04:00
|
|
|
$dbh->bz_lock_tables('profiles WRITE', 'profiles_activity WRITE',
|
2005-12-21 01:16:09 +03:00
|
|
|
'user_group_map WRITE', 'email_setting WRITE',
|
2006-06-08 00:31:10 +04:00
|
|
|
'groups READ', 'tokens READ', 'fielddefs READ');
|
2005-07-28 00:15:37 +04:00
|
|
|
|
2005-02-09 09:42:43 +03:00
|
|
|
if (!is_available_username($login)) {
|
2005-07-28 00:15:37 +04:00
|
|
|
# Account already exists
|
|
|
|
$dbh->bz_unlock_tables();
|
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
|
|
|
|
2005-03-30 13:57:29 +04:00
|
|
|
if ($login !~ /$createexp/) {
|
2002-12-09 03:24:43 +03:00
|
|
|
ThrowUserError("account_creation_disabled");
|
|
|
|
}
|
2002-01-30 02:26:37 +03:00
|
|
|
|
2005-07-28 00:15:37 +04:00
|
|
|
# Create account
|
|
|
|
my $password = insert_new_user($login, $realname);
|
|
|
|
|
|
|
|
$dbh->bz_unlock_tables();
|
|
|
|
|
2005-03-30 13:57:29 +04:00
|
|
|
# Clear out the login cookies in case the user is currently logged in.
|
|
|
|
Bugzilla->logout();
|
|
|
|
|
2005-07-11 04:40:59 +04:00
|
|
|
Bugzilla::BugMail::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());
|