2003-03-27 03:07:02 +03:00
|
|
|
#!/usr/bin/perl -wT
|
2001-07-11 09:29:21 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# 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): Myk Melez <myk@mozilla.org>
|
2006-08-19 22:12:00 +04:00
|
|
|
# Frédéric Buclin <LpSolit@gmail.com>
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
############################################################################
|
|
|
|
# Script Initialization
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
# Make it harder for us to do dangerous things in Perl.
|
|
|
|
use strict;
|
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
use lib qw(.);
|
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
use Bugzilla;
|
2004-03-27 06:51:44 +03:00
|
|
|
use Bugzilla::Constants;
|
2005-07-13 07:57:02 +04:00
|
|
|
use Bugzilla::Util;
|
2006-06-21 04:44:48 +04:00
|
|
|
use Bugzilla::Error;
|
|
|
|
use Bugzilla::Token;
|
|
|
|
use Bugzilla::User;
|
2004-03-27 06:51:44 +03:00
|
|
|
|
2006-08-19 22:12:00 +04:00
|
|
|
use Date::Parse;
|
|
|
|
|
2005-07-08 06:31:43 +04:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2006-07-06 10:12:05 +04:00
|
|
|
local our $cgi = Bugzilla->cgi;
|
|
|
|
local our $template = Bugzilla->template;
|
|
|
|
local our $vars = {};
|
2003-05-05 05:15:38 +04:00
|
|
|
|
2004-03-27 06:51:44 +03:00
|
|
|
Bugzilla->login(LOGIN_OPTIONAL);
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Data Validation / Security Authorization
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Throw an error if the form does not contain an "action" field specifying
|
|
|
|
# what the user wants to do.
|
2004-02-29 17:19:27 +03:00
|
|
|
$cgi->param('a') || ThrowCodeError("unknown_action");
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
# Assign the action to a global variable.
|
2004-02-29 17:19:27 +03:00
|
|
|
$::action = $cgi->param('a');
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
# If a token was submitted, make sure it is a valid token that exists in the
|
|
|
|
# database and is the correct type for the action being taken.
|
2004-02-29 17:19:27 +03:00
|
|
|
if ($cgi->param('t')) {
|
2001-07-11 09:29:21 +04:00
|
|
|
# Assign the token and its SQL quoted equivalent to global variables.
|
2004-02-29 17:19:27 +03:00
|
|
|
$::token = $cgi->param('t');
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
# Make sure the token contains only valid characters in the right amount.
|
2006-10-20 22:52:24 +04:00
|
|
|
# validate_password will throw an error if token is invalid
|
2006-05-08 00:13:49 +04:00
|
|
|
validate_password($::token);
|
2002-04-02 02:52:40 +04:00
|
|
|
|
2004-03-18 06:57:05 +03:00
|
|
|
Bugzilla::Token::CleanTokenTable();
|
2002-04-02 02:52:40 +04:00
|
|
|
|
2001-07-11 09:29:21 +04:00
|
|
|
# Make sure the token exists in the database.
|
2005-10-12 05:16:54 +04:00
|
|
|
my ($tokentype) = $dbh->selectrow_array('SELECT tokentype FROM tokens
|
|
|
|
WHERE token = ?', undef, $::token);
|
|
|
|
$tokentype || ThrowUserError("token_inexistent");
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
# Make sure the token is the correct type for the action being taken.
|
|
|
|
if ( grep($::action eq $_ , qw(cfmpw cxlpw chgpw)) && $tokentype ne 'password' ) {
|
2004-03-18 06:57:05 +03:00
|
|
|
Bugzilla::Token::Cancel($::token, "wrong_token_for_changing_passwd");
|
2002-09-30 11:22:44 +04:00
|
|
|
ThrowUserError("wrong_token_for_changing_passwd");
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
2002-04-02 02:52:40 +04:00
|
|
|
if ( ($::action eq 'cxlem')
|
|
|
|
&& (($tokentype ne 'emailold') && ($tokentype ne 'emailnew')) ) {
|
2004-03-18 06:57:05 +03:00
|
|
|
Bugzilla::Token::Cancel($::token, "wrong_token_for_cancelling_email_change");
|
2002-09-30 11:22:44 +04:00
|
|
|
ThrowUserError("wrong_token_for_cancelling_email_change");
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
if ( grep($::action eq $_ , qw(cfmem chgem))
|
|
|
|
&& ($tokentype ne 'emailnew') ) {
|
2004-03-18 06:57:05 +03:00
|
|
|
Bugzilla::Token::Cancel($::token, "wrong_token_for_confirming_email_change");
|
2002-09-30 11:22:44 +04:00
|
|
|
ThrowUserError("wrong_token_for_confirming_email_change");
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
2006-08-19 22:12:00 +04:00
|
|
|
if (($::action =~ /^(request|confirm|cancel)_new_account$/)
|
|
|
|
&& ($tokentype ne 'account'))
|
|
|
|
{
|
|
|
|
Bugzilla::Token::Cancel($::token, 'wrong_token_for_creating_account');
|
|
|
|
ThrowUserError('wrong_token_for_creating_account');
|
|
|
|
}
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
2004-07-21 02:41:22 +04:00
|
|
|
|
2001-07-11 09:29:21 +04:00
|
|
|
# If the user is requesting a password change, make sure they submitted
|
2004-07-21 02:41:22 +04:00
|
|
|
# their login name and it exists in the database, and that the DB module is in
|
2006-06-19 19:41:01 +04:00
|
|
|
# the list of allowed verification methods.
|
2006-10-20 22:52:24 +04:00
|
|
|
my $login_name;
|
2001-07-11 09:29:21 +04:00
|
|
|
if ( $::action eq 'reqpw' ) {
|
2006-10-20 22:52:24 +04:00
|
|
|
$login_name = $cgi->param('loginname');
|
|
|
|
defined $login_name
|
2002-09-30 11:22:44 +04:00
|
|
|
|| ThrowUserError("login_needed_for_password_change");
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2004-07-21 02:41:22 +04:00
|
|
|
# check verification methods
|
2006-05-12 06:41:22 +04:00
|
|
|
unless (Bugzilla->user->authorizer->can_change_password) {
|
2004-07-21 02:41:22 +04:00
|
|
|
ThrowUserError("password_change_requests_not_allowed");
|
|
|
|
}
|
|
|
|
|
2006-10-20 22:52:24 +04:00
|
|
|
validate_email_syntax($login_name)
|
|
|
|
|| ThrowUserError('illegal_email_address', {addr => $login_name});
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2005-10-12 05:16:54 +04:00
|
|
|
my ($user_id) = $dbh->selectrow_array('SELECT userid FROM profiles WHERE ' .
|
|
|
|
$dbh->sql_istrcmp('login_name', '?'),
|
2006-10-20 22:52:24 +04:00
|
|
|
undef, $login_name);
|
2005-10-12 05:16:54 +04:00
|
|
|
$user_id || ThrowUserError("account_inexistent");
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# If the user is changing their password, make sure they submitted a new
|
|
|
|
# password and that the new password is valid.
|
2006-10-20 22:52:24 +04:00
|
|
|
my $password;
|
2001-07-11 09:29:21 +04:00
|
|
|
if ( $::action eq 'chgpw' ) {
|
2006-10-20 22:52:24 +04:00
|
|
|
$password = $cgi->param('password');
|
|
|
|
defined $password
|
2004-02-29 17:19:27 +03:00
|
|
|
&& defined $cgi->param('matchpassword')
|
2002-09-30 11:22:44 +04:00
|
|
|
|| ThrowUserError("require_new_password");
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2006-10-20 22:52:24 +04:00
|
|
|
validate_password($password, $cgi->param('matchpassword'));
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Main Body Execution
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# All calls to this script should contain an "action" variable whose value
|
|
|
|
# determines what the user wants to do. The code below checks the value of
|
|
|
|
# that variable and runs the appropriate code.
|
|
|
|
|
|
|
|
if ($::action eq 'reqpw') {
|
2006-10-20 22:52:24 +04:00
|
|
|
requestChangePassword($login_name);
|
2001-07-11 09:29:21 +04:00
|
|
|
} elsif ($::action eq 'cfmpw') {
|
|
|
|
confirmChangePassword();
|
|
|
|
} elsif ($::action eq 'cxlpw') {
|
|
|
|
cancelChangePassword();
|
|
|
|
} elsif ($::action eq 'chgpw') {
|
2006-10-20 22:52:24 +04:00
|
|
|
changePassword($password);
|
2002-04-02 02:52:40 +04:00
|
|
|
} elsif ($::action eq 'cfmem') {
|
|
|
|
confirmChangeEmail();
|
|
|
|
} elsif ($::action eq 'cxlem') {
|
|
|
|
cancelChangeEmail();
|
|
|
|
} elsif ($::action eq 'chgem') {
|
|
|
|
changeEmail();
|
2006-08-19 22:12:00 +04:00
|
|
|
} elsif ($::action eq 'request_new_account') {
|
|
|
|
request_create_account();
|
|
|
|
} elsif ($::action eq 'confirm_new_account') {
|
|
|
|
confirm_create_account();
|
|
|
|
} elsif ($::action eq 'cancel_new_account') {
|
|
|
|
cancel_create_account();
|
2001-07-11 09:29:21 +04:00
|
|
|
} else {
|
|
|
|
# If the action that the user wants to take (specified in the "a" form field)
|
|
|
|
# is none of the above listed actions, display an error telling the user
|
|
|
|
# that we do not understand what they would like to do.
|
2003-09-14 10:05:23 +04:00
|
|
|
ThrowCodeError("unknown_action", { action => $::action });
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Functions
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
sub requestChangePassword {
|
2006-10-20 22:52:24 +04:00
|
|
|
my ($login_name) = @_;
|
|
|
|
Bugzilla::Token::IssuePasswordToken($login_name);
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2002-08-10 12:06:58 +04:00
|
|
|
$vars->{'message'} = "password_change_request";
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2002-03-16 02:23:12 +03:00
|
|
|
$template->process("global/message.html.tmpl", $vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub confirmChangePassword {
|
2002-03-16 02:23:12 +03:00
|
|
|
$vars->{'token'} = $::token;
|
|
|
|
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("account/password/set-forgotten-password.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
2002-03-16 02:23:12 +03:00
|
|
|
sub cancelChangePassword {
|
2007-03-11 07:11:18 +03:00
|
|
|
$vars->{'message'} = "password_change_canceled";
|
2004-03-18 06:57:05 +03:00
|
|
|
Bugzilla::Token::Cancel($::token, $vars->{'message'});
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2002-03-16 02:23:12 +03:00
|
|
|
$template->process("global/message.html.tmpl", $vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub changePassword {
|
2006-10-20 22:52:24 +04:00
|
|
|
my ($password) = @_;
|
2005-02-18 00:57:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
|
2005-10-12 05:16:54 +04:00
|
|
|
# Create a crypted version of the new password
|
2006-10-20 22:52:24 +04:00
|
|
|
my $cryptedpassword = bz_crypt($password);
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
# Get the user's ID from the tokens table.
|
2005-10-12 05:16:54 +04:00
|
|
|
my ($userid) = $dbh->selectrow_array('SELECT userid FROM tokens
|
|
|
|
WHERE token = ?', undef, $::token);
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
# Update the user's password in the profiles table and delete the token
|
|
|
|
# from the tokens table.
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_lock_tables('profiles WRITE', 'tokens WRITE');
|
2005-10-12 05:16:54 +04:00
|
|
|
$dbh->do(q{UPDATE profiles
|
|
|
|
SET cryptpassword = ?
|
|
|
|
WHERE userid = ?},
|
|
|
|
undef, ($cryptedpassword, $userid) );
|
|
|
|
$dbh->do('DELETE FROM tokens WHERE token = ?', undef, $::token);
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables();
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2004-03-27 04:28:29 +03:00
|
|
|
Bugzilla->logout_user_by_id($userid);
|
2002-02-04 15:23:05 +03:00
|
|
|
|
2002-08-10 12:06:58 +04:00
|
|
|
$vars->{'message'} = "password_changed";
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2002-03-16 02:23:12 +03:00
|
|
|
$template->process("global/message.html.tmpl", $vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
2002-04-02 02:52:40 +04:00
|
|
|
sub confirmChangeEmail {
|
|
|
|
# Return HTTP response headers.
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2002-04-02 02:52:40 +04:00
|
|
|
|
|
|
|
$vars->{'token'} = $::token;
|
|
|
|
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("account/email/confirm.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub changeEmail {
|
2005-02-18 00:57:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2002-04-02 02:52:40 +04:00
|
|
|
|
|
|
|
# Get the user's ID from the tokens table.
|
2005-10-12 05:16:54 +04:00
|
|
|
my ($userid, $eventdata) = $dbh->selectrow_array(
|
|
|
|
q{SELECT userid, eventdata FROM tokens
|
|
|
|
WHERE token = ?}, undef, $::token);
|
2002-04-02 02:52:40 +04:00
|
|
|
my ($old_email, $new_email) = split(/:/,$eventdata);
|
|
|
|
|
|
|
|
# Check the user entered the correct old email address
|
2004-02-29 17:19:27 +03:00
|
|
|
if(lc($cgi->param('email')) ne lc($old_email)) {
|
2002-09-30 11:22:44 +04:00
|
|
|
ThrowUserError("email_confirmation_failed");
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
# The new email address should be available as this was
|
|
|
|
# confirmed initially so cancel token if it is not still available
|
2005-02-09 09:42:43 +03:00
|
|
|
if (! is_available_username($new_email,$old_email)) {
|
2004-03-18 12:01:35 +03:00
|
|
|
$vars->{'email'} = $new_email; # Needed for Bugzilla::Token::Cancel's mail
|
2005-10-25 03:11:56 +04:00
|
|
|
Bugzilla::Token::Cancel($::token, "account_exists", $vars);
|
2003-04-02 16:35:07 +04:00
|
|
|
ThrowUserError("account_exists", { email => $new_email } );
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Update the user's login name in the profiles table and delete the token
|
|
|
|
# from the tokens table.
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_lock_tables('profiles WRITE', 'tokens WRITE');
|
2005-10-12 05:16:54 +04:00
|
|
|
$dbh->do(q{UPDATE profiles
|
|
|
|
SET login_name = ?
|
|
|
|
WHERE userid = ?},
|
|
|
|
undef, ($new_email, $userid));
|
|
|
|
$dbh->do('DELETE FROM tokens WHERE token = ?', undef, $::token);
|
|
|
|
$dbh->do(q{DELETE FROM tokens WHERE userid = ?
|
|
|
|
AND tokentype = 'emailnew'}, undef, $userid);
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables();
|
2003-06-03 13:48:15 +04:00
|
|
|
|
|
|
|
# The email address has been changed, so we need to rederive the groups
|
|
|
|
my $user = new Bugzilla::User($userid);
|
2005-08-19 00:09:37 +04:00
|
|
|
$user->derive_regexp_groups;
|
2002-04-02 02:52:40 +04:00
|
|
|
|
|
|
|
# Return HTTP response headers.
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2002-04-02 02:52:40 +04:00
|
|
|
|
|
|
|
# Let the user know their email address has been changed.
|
|
|
|
|
2002-08-10 12:06:58 +04:00
|
|
|
$vars->{'message'} = "login_changed";
|
2002-04-02 02:52:40 +04:00
|
|
|
|
|
|
|
$template->process("global/message.html.tmpl", $vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub cancelChangeEmail {
|
2005-02-18 00:57:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
|
2002-04-02 02:52:40 +04:00
|
|
|
# Get the user's ID from the tokens table.
|
2005-10-12 05:16:54 +04:00
|
|
|
my ($userid, $tokentype, $eventdata) = $dbh->selectrow_array(
|
|
|
|
q{SELECT userid, tokentype, eventdata FROM tokens
|
|
|
|
WHERE token = ?}, undef, $::token);
|
2002-04-02 02:52:40 +04:00
|
|
|
my ($old_email, $new_email) = split(/:/,$eventdata);
|
|
|
|
|
|
|
|
if($tokentype eq "emailold") {
|
2007-03-11 07:11:18 +03:00
|
|
|
$vars->{'message'} = "emailold_change_canceled";
|
2002-04-02 02:52:40 +04:00
|
|
|
|
2005-10-12 05:16:54 +04:00
|
|
|
my $actualemail = $dbh->selectrow_array(
|
|
|
|
q{SELECT login_name FROM profiles
|
|
|
|
WHERE userid = ?}, undef, $userid);
|
2002-04-02 02:52:40 +04:00
|
|
|
|
|
|
|
# check to see if it has been altered
|
|
|
|
if($actualemail ne $old_email) {
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_lock_tables('profiles WRITE');
|
2005-10-12 05:16:54 +04:00
|
|
|
$dbh->do(q{UPDATE profiles
|
|
|
|
SET login_name = ?
|
|
|
|
WHERE userid = ?},
|
|
|
|
undef, ($old_email, $userid));
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables();
|
2003-06-03 13:48:15 +04:00
|
|
|
|
|
|
|
# email has changed, so rederive groups
|
|
|
|
# Note that this is done _after_ the tables are unlocked
|
|
|
|
# This is sort of a race condition (given the lack of transactions)
|
|
|
|
# but the user had access to it just now, so it's not a security
|
|
|
|
# issue
|
|
|
|
|
|
|
|
my $user = new Bugzilla::User($userid);
|
2005-08-19 00:09:37 +04:00
|
|
|
$user->derive_regexp_groups;
|
2003-06-03 13:48:15 +04:00
|
|
|
|
2007-03-11 07:11:18 +03:00
|
|
|
$vars->{'message'} = "email_change_canceled_reinstated";
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2007-03-11 07:11:18 +03:00
|
|
|
$vars->{'message'} = 'email_change_canceled'
|
2002-09-30 11:22:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
$vars->{'old_email'} = $old_email;
|
|
|
|
$vars->{'new_email'} = $new_email;
|
2005-10-25 03:11:56 +04:00
|
|
|
Bugzilla::Token::Cancel($::token, $vars->{'message'}, $vars);
|
2002-04-02 02:52:40 +04:00
|
|
|
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_lock_tables('tokens WRITE');
|
2005-10-12 05:16:54 +04:00
|
|
|
$dbh->do(q{DELETE FROM tokens WHERE userid = ?
|
|
|
|
AND tokentype = 'emailold' OR tokentype = 'emailnew'},
|
|
|
|
undef, $userid);
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables();
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2002-04-02 02:52:40 +04:00
|
|
|
# Return HTTP response headers.
|
2004-02-29 17:19:27 +03:00
|
|
|
print $cgi->header();
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2002-04-02 02:52:40 +04:00
|
|
|
$template->process("global/message.html.tmpl", $vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
2001-07-11 09:29:21 +04:00
|
|
|
|
2006-08-19 22:12:00 +04:00
|
|
|
sub request_create_account {
|
|
|
|
my (undef, $date, $login_name) = Bugzilla::Token::GetTokenData($::token);
|
|
|
|
$vars->{'token'} = $::token;
|
|
|
|
$vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'};
|
|
|
|
$vars->{'date'} = str2time($date);
|
|
|
|
|
|
|
|
# We require a HTTPS connection if possible.
|
|
|
|
if (Bugzilla->params->{'sslbase'} ne ''
|
|
|
|
&& Bugzilla->params->{'ssl'} ne 'never')
|
|
|
|
{
|
|
|
|
$cgi->require_https(Bugzilla->params->{'sslbase'});
|
|
|
|
}
|
|
|
|
print $cgi->header();
|
|
|
|
|
|
|
|
$template->process('account/email/confirm-new.html.tmpl', $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
|
|
|
|
sub confirm_create_account {
|
|
|
|
my (undef, undef, $login_name) = Bugzilla::Token::GetTokenData($::token);
|
|
|
|
|
2006-10-20 22:52:24 +04:00
|
|
|
my $password = $cgi->param('passwd1') || '';
|
|
|
|
validate_password($password, $cgi->param('passwd2') || '');
|
2006-08-26 02:10:39 +04:00
|
|
|
|
|
|
|
my $otheruser = Bugzilla::User->create({
|
|
|
|
login_name => $login_name,
|
|
|
|
realname => $cgi->param('realname'),
|
2006-10-20 22:52:24 +04:00
|
|
|
cryptpassword => $password});
|
2006-08-19 22:12:00 +04:00
|
|
|
|
|
|
|
# Now delete this token.
|
2006-10-15 02:02:13 +04:00
|
|
|
delete_token($::token);
|
2006-08-19 22:12:00 +04:00
|
|
|
|
|
|
|
# Let the user know that his user account has been successfully created.
|
|
|
|
$vars->{'message'} = 'account_created';
|
|
|
|
$vars->{'otheruser'} = $otheruser;
|
|
|
|
$vars->{'login_info'} = 1;
|
|
|
|
|
|
|
|
print $cgi->header();
|
|
|
|
|
|
|
|
$template->process('global/message.html.tmpl', $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
|
|
|
|
sub cancel_create_account {
|
|
|
|
my (undef, undef, $login_name) = Bugzilla::Token::GetTokenData($::token);
|
|
|
|
|
2007-03-11 07:11:18 +03:00
|
|
|
$vars->{'message'} = 'account_creation_canceled';
|
2006-08-19 22:12:00 +04:00
|
|
|
$vars->{'account'} = $login_name;
|
|
|
|
Bugzilla::Token::Cancel($::token, $vars->{'message'});
|
|
|
|
|
|
|
|
print $cgi->header();
|
|
|
|
$template->process('global/message.html.tmpl', $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|