Commit 3891b63a authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 218917 - Allow the login name to be different from the email address

Original patch by Gervase Markham r=gerv a=dkl
parent c44470a3
...@@ -509,7 +509,7 @@ sub _translate_comment { ...@@ -509,7 +509,7 @@ sub _translate_comment {
my $comment_hash = { my $comment_hash = {
id => as_int($comment->id), id => as_int($comment->id),
bug_id => as_int($comment->bug_id), bug_id => as_int($comment->bug_id),
creator => as_email($comment->author->login), creator => as_login($comment->author->login),
time => as_datetime($comment->creation_ts), time => as_datetime($comment->creation_ts),
creation_time => as_datetime($comment->creation_ts), creation_time => as_datetime($comment->creation_ts),
is_private => as_boolean($comment->is_private), is_private => as_boolean($comment->is_private),
...@@ -1431,7 +1431,7 @@ sub _bug_to_hash { ...@@ -1431,7 +1431,7 @@ sub _bug_to_hash {
$item{alias} = as_string_array($bug->alias); $item{alias} = as_string_array($bug->alias);
} }
if (filter_wants $params, 'assigned_to') { if (filter_wants $params, 'assigned_to') {
$item{'assigned_to'} = as_email($bug->assigned_to->login); $item{'assigned_to'} = as_login($bug->assigned_to->login);
$item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to'); $item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to');
} }
if (filter_wants $params, 'blocks') { if (filter_wants $params, 'blocks') {
...@@ -1444,14 +1444,14 @@ sub _bug_to_hash { ...@@ -1444,14 +1444,14 @@ sub _bug_to_hash {
$item{component} = as_string($bug->component); $item{component} = as_string($bug->component);
} }
if (filter_wants $params, 'cc') { if (filter_wants $params, 'cc') {
$item{'cc'} = as_email_array($bug->cc); $item{'cc'} = as_login_array($bug->cc);
$item{'cc_detail'} = [ map { $self->_user_to_hash($_, $params, undef, 'cc') } @{ $bug->cc_users } ]; $item{'cc_detail'} = [ map { $self->_user_to_hash($_, $params, undef, 'cc') } @{ $bug->cc_users } ];
} }
if (filter_wants $params, 'creation_time') { if (filter_wants $params, 'creation_time') {
$item{'creation_time'} = as_datetime($bug->creation_ts); $item{'creation_time'} = as_datetime($bug->creation_ts);
} }
if (filter_wants $params, 'creator') { if (filter_wants $params, 'creator') {
$item{'creator'} = as_email($bug->reporter->login); $item{'creator'} = as_login($bug->reporter->login);
$item{'creator_detail'} = $self->_user_to_hash($bug->reporter, $params, undef, 'creator'); $item{'creator_detail'} = $self->_user_to_hash($bug->reporter, $params, undef, 'creator');
} }
if (filter_wants $params, 'depends_on') { if (filter_wants $params, 'depends_on') {
...@@ -1477,7 +1477,7 @@ sub _bug_to_hash { ...@@ -1477,7 +1477,7 @@ sub _bug_to_hash {
} }
if (filter_wants $params, 'qa_contact') { if (filter_wants $params, 'qa_contact') {
my $qa_login = $bug->qa_contact ? $bug->qa_contact->login : ''; my $qa_login = $bug->qa_contact ? $bug->qa_contact->login : '';
$item{'qa_contact'} = as_email($qa_login); $item{'qa_contact'} = as_login($qa_login);
if ($bug->qa_contact) { if ($bug->qa_contact) {
$item{'qa_contact_detail'} = $self->_user_to_hash($bug->qa_contact, $params, undef, 'qa_contact'); $item{'qa_contact_detail'} = $self->_user_to_hash($bug->qa_contact, $params, undef, 'qa_contact');
} }
...@@ -1546,8 +1546,7 @@ sub _user_to_hash { ...@@ -1546,8 +1546,7 @@ sub _user_to_hash {
my $item = filter $filters, { my $item = filter $filters, {
id => as_int($user->id), id => as_int($user->id),
real_name => as_string($user->name), real_name => as_string($user->name),
name => as_email($user->login), name => as_login($user->login),
email => as_email($user->email),
}, $types, $prefix; }, $types, $prefix;
return $item; return $item;
} }
...@@ -1571,7 +1570,7 @@ sub _attachment_to_hash { ...@@ -1571,7 +1570,7 @@ sub _attachment_to_hash {
# creator requires an extra lookup, so we only send them if # creator requires an extra lookup, so we only send them if
# the filter wants them. # the filter wants them.
if (filter_wants $filters, 'creator', $types, $prefix) { if (filter_wants $filters, 'creator', $types, $prefix) {
$item->{'creator'} = as_email($attach->attacher->login); $item->{'creator'} = as_login($attach->attacher->login);
} }
if (filter_wants $filters, 'data', $types, $prefix) { if (filter_wants $filters, 'data', $types, $prefix) {
...@@ -1603,7 +1602,7 @@ sub _flag_to_hash { ...@@ -1603,7 +1602,7 @@ sub _flag_to_hash {
foreach my $field (qw(setter requestee)) { foreach my $field (qw(setter requestee)) {
my $field_id = $field . "_id"; my $field_id = $field . "_id";
$item->{$field} = as_email($flag->$field->login) $item->{$field} = as_login($flag->$field->login)
if $flag->$field_id; if $flag->$field_id;
} }
...@@ -2672,10 +2671,6 @@ C<string> The 'real' name for this user, if any. ...@@ -2672,10 +2671,6 @@ C<string> The 'real' name for this user, if any.
C<string> The user's Bugzilla login. C<string> The user's Bugzilla login.
=item C<email>
C<string> The user's email address. Currently this is the same value as the name.
=back =back
=back =back
......
...@@ -69,7 +69,6 @@ use constant PARAMETERS_LOGGED_IN => qw( ...@@ -69,7 +69,6 @@ use constant PARAMETERS_LOGGED_IN => qw(
defaultseverity defaultseverity
duplicate_or_move_bug_status duplicate_or_move_bug_status
emailregexpdesc emailregexpdesc
emailsuffix
letsubmitterchoosemilestone letsubmitterchoosemilestone
letsubmitterchoosepriority letsubmitterchoosepriority
mailfrom mailfrom
...@@ -82,6 +81,7 @@ use constant PARAMETERS_LOGGED_IN => qw( ...@@ -82,6 +81,7 @@ use constant PARAMETERS_LOGGED_IN => qw(
requirelogin requirelogin
search_allow_no_criteria search_allow_no_criteria
urlbase urlbase
use_email_as_login
use_see_also use_see_also
useclassification useclassification
usemenuforusers usemenuforusers
...@@ -449,7 +449,6 @@ A logged-in user can access the following parameters (listed alphabetically): ...@@ -449,7 +449,6 @@ A logged-in user can access the following parameters (listed alphabetically):
C<defaultseverity>, C<defaultseverity>,
C<duplicate_or_move_bug_status>, C<duplicate_or_move_bug_status>,
C<emailregexpdesc>, C<emailregexpdesc>,
C<emailsuffix>,
C<letsubmitterchoosemilestone>, C<letsubmitterchoosemilestone>,
C<letsubmitterchoosepriority>, C<letsubmitterchoosepriority>,
C<mailfrom>, C<mailfrom>,
...@@ -462,6 +461,7 @@ A logged-in user can access the following parameters (listed alphabetically): ...@@ -462,6 +461,7 @@ A logged-in user can access the following parameters (listed alphabetically):
C<requirelogin>, C<requirelogin>,
C<search_allow_no_criteria>, C<search_allow_no_criteria>,
C<urlbase>, C<urlbase>,
C<use_email_as_login>,
C<use_see_also>, C<use_see_also>,
C<useclassification>, C<useclassification>,
C<usemenuforusers>, C<usemenuforusers>,
......
...@@ -247,8 +247,8 @@ sub _get_group_membership { ...@@ -247,8 +247,8 @@ sub _get_group_membership {
map {{ map {{
id => as_int($_->id), id => as_int($_->id),
real_name => as_string($_->name), real_name => as_string($_->name),
name => as_string($_->login), name => as_login($_->login),
email => as_string($_->email), email => as_email($_->email),
can_login => as_boolean($_->is_enabled), can_login => as_boolean($_->is_enabled),
email_enabled => as_boolean($_->email_enabled), email_enabled => as_boolean($_->email_enabled),
login_denied_text => as_string($_->disabledtext), login_denied_text => as_string($_->disabledtext),
...@@ -571,12 +571,12 @@ C<string> The actual name of the user. ...@@ -571,12 +571,12 @@ C<string> The actual name of the user.
=item email =item email
C<string> The email address of the user. C<string> If you are in the editusers group, returns the email address of the
user, else returns nothing.
=item name =item name
C<string> The login name of the user. Note that in some situations this is C<string> The login name of the user.
different than their email.
=item can_login =item can_login
......
...@@ -322,9 +322,9 @@ sub _component_to_hash { ...@@ -322,9 +322,9 @@ sub _component_to_hash {
name => as_string($component->name), name => as_string($component->name),
description => as_string($component->description), description => as_string($component->description),
default_assigned_to => default_assigned_to =>
as_email($component->default_assignee->login), as_login($component->default_assignee->login),
default_qa_contact => default_qa_contact =>
as_email($component->default_qa_contact ? as_login($component->default_qa_contact ?
$component->default_qa_contact->login : ""), $component->default_qa_contact->login : ""),
sort_key => 0, # sort_key is returned to match Bug.fields sort_key => 0, # sort_key is returned to match Bug.fields
is_active => as_boolean($component->is_active), is_active => as_boolean($component->is_active),
......
...@@ -53,13 +53,11 @@ use constant PUBLIC_METHODS => qw( ...@@ -53,13 +53,11 @@ use constant PUBLIC_METHODS => qw(
); );
use constant MAPPED_FIELDS => { use constant MAPPED_FIELDS => {
email => 'login',
full_name => 'name', full_name => 'name',
login_denied_text => 'disabledtext', login_denied_text => 'disabledtext',
}; };
use constant MAPPED_RETURNS => { use constant MAPPED_RETURNS => {
login_name => 'email',
realname => 'full_name', realname => 'full_name',
disabledtext => 'login_denied_text', disabledtext => 'login_denied_text',
}; };
...@@ -158,8 +156,11 @@ sub offer_account_by_email { ...@@ -158,8 +156,11 @@ sub offer_account_by_email {
my $email = trim($params->{email}) my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' }); || ThrowCodeError('param_required', { param => 'email' });
my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
$login or ThrowCodeError('param_required', { param => 'login' });
Bugzilla->user->check_account_creation_enabled; Bugzilla->user->check_account_creation_enabled;
Bugzilla->user->check_and_send_account_creation_confirmation($email); Bugzilla->user->check_and_send_account_creation_confirmation($login, $email);
return undef; return undef;
} }
...@@ -174,11 +175,16 @@ sub create { ...@@ -174,11 +175,16 @@ sub create {
my $email = trim($params->{email}) my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' }); || ThrowCodeError('param_required', { param => 'email' });
my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
$login or ThrowCodeError('param_required', { param => 'login' });
my $realname = trim($params->{full_name}); my $realname = trim($params->{full_name});
my $password = trim($params->{password}) || '*'; my $password = trim($params->{password}) || '*';
my $user = Bugzilla::User->create({ my $user = Bugzilla::User->create({
login_name => $email, login_name => $login,
email => $email,
realname => $realname, realname => $realname,
cryptpassword => $password cryptpassword => $password
}); });
...@@ -225,7 +231,7 @@ sub get { ...@@ -225,7 +231,7 @@ sub get {
@users = map { filter $params, { @users = map { filter $params, {
id => as_int($_->id), id => as_int($_->id),
real_name => as_string($_->name), real_name => as_string($_->name),
name => as_email($_->login), name => as_login($_->login),
} } @$in_group; } } @$in_group;
return { users => \@users }; return { users => \@users };
...@@ -277,12 +283,12 @@ sub get { ...@@ -277,12 +283,12 @@ sub get {
my $user_info = filter $params, { my $user_info = filter $params, {
id => as_int($user->id), id => as_int($user->id),
real_name => as_string($user->name), real_name => as_string($user->name),
name => as_email($user->login), name => as_login($user->login),
email => as_email($user->email),
can_login => as_boolean($user->is_enabled ? 1 : 0), can_login => as_boolean($user->is_enabled ? 1 : 0),
}; };
if (Bugzilla->user->in_group('editusers')) { if (Bugzilla->user->in_group('editusers')) {
$user_info->{email} = as_email($user->email),
$user_info->{email_enabled} = as_boolean($user->email_enabled); $user_info->{email_enabled} = as_boolean($user->email_enabled);
$user_info->{login_denied_text} = as_string($user->disabledtext); $user_info->{login_denied_text} = as_string($user->disabledtext);
} }
...@@ -651,6 +657,8 @@ This is the recommended way to create a Bugzilla account. ...@@ -651,6 +657,8 @@ This is the recommended way to create a Bugzilla account.
=item C<email> (string) - the email to send the offer to. =item C<email> (string) - the email to send the offer to.
=item C<login> (string) - the login of the user account.
=back =back
=item B<Returns> (nothing) =item B<Returns> (nothing)
...@@ -699,6 +707,11 @@ are the same as below. ...@@ -699,6 +707,11 @@ are the same as below.
=item C<email> (string) - The email address for the new user. =item C<email> (string) - The email address for the new user.
=item C<login> (string) - The login name for the new user.
If the installation has the C<use_email_as_login> parameter switched on, then
this parameter is ignored, and the value of the C<email> parameter will
be used as the login name for the new account.
=item C<full_name> (string) B<Optional> - The user's full name. Will =item C<full_name> (string) B<Optional> - The user's full name. Will
be set to empty if not specified. be set to empty if not specified.
...@@ -768,7 +781,7 @@ C<array> Contains ids of user to update. ...@@ -768,7 +781,7 @@ C<array> Contains ids of user to update.
=item C<names> =item C<names>
C<array> Contains email/login of user to update. C<array> Contains login of user to update.
=item C<full_name> =item C<full_name>
...@@ -996,8 +1009,7 @@ C<string> The email address of the user. ...@@ -996,8 +1009,7 @@ C<string> The email address of the user.
=item name =item name
C<string> The login name of the user. Note that in some situations this is C<string> The login name of the user.
different than their email.
=item can_login =item can_login
...@@ -1083,7 +1095,7 @@ C<string> The CGI parameters for the saved report. ...@@ -1083,7 +1095,7 @@ C<string> The CGI parameters for the saved report.
B<Note>: If you are not logged in to Bugzilla when you call this function, you B<Note>: If you are not logged in to Bugzilla when you call this function, you
will only be returned the C<id>, C<name>, and C<real_name> items. If you are will only be returned the C<id>, C<name>, and C<real_name> items. If you are
logged in and not in editusers group, you will only be returned the C<id>, C<name>, logged in and not in editusers group, you will only be returned the C<id>, C<name>,
C<real_name>, C<email>, C<can_login>, and C<groups> items. The groups returned are C<real_name>, C<can_login>, and C<groups> items. The groups returned are
filtered based on your permission to bless each group. filtered based on your permission to bless each group.
The C<saved_searches> and C<saved_reports> items are only returned if you are The C<saved_searches> and C<saved_reports> items are only returned if you are
querying your own account, even if you are in the editusers group. querying your own account, even if you are in the editusers group.
......
...@@ -33,9 +33,10 @@ our @EXPORT = qw( ...@@ -33,9 +33,10 @@ our @EXPORT = qw(
as_datetime as_datetime
as_double as_double
as_email as_email
as_email_array
as_int as_int
as_int_array as_int_array
as_login
as_login_array
as_name_array as_name_array
as_string as_string
as_string_array as_string_array
...@@ -367,8 +368,8 @@ sub as_string { defined $_[0] ? $_[0] . '' : JSON::null } ...@@ -367,8 +368,8 @@ sub as_string { defined $_[0] ? $_[0] . '' : JSON::null }
# array types # array types
sub as_email_array { [ map { as_email($_) } @{ $_[0] // [] } ] }
sub as_int_array { [ map { as_int($_) } @{ $_[0] // [] } ] } sub as_int_array { [ map { as_int($_) } @{ $_[0] // [] } ] }
sub as_login_array { [ map { as_login($_) } @{ $_[0] // [] } ] }
sub as_name_array { [ map { as_string($_->name) } @{ $_[0] // [] } ] } sub as_name_array { [ map { as_string($_->name) } @{ $_[0] // [] } ] }
sub as_string_array { [ map { as_string($_) } @{ $_[0] // [] } ] } sub as_string_array { [ map { as_string($_) } @{ $_[0] // [] } ] }
...@@ -380,10 +381,14 @@ sub as_datetime { ...@@ -380,10 +381,14 @@ sub as_datetime {
: JSON::null; : JSON::null;
} }
sub as_email { sub as_login {
defined $_[0] defined $_[0]
? ( Bugzilla->params->{webservice_email_filter} ? email_filter($_[0]) : $_[0] . '' ) ? ( Bugzilla->params->{use_email_as_login} ? email_filter($_[0]) : $_[0] . '' )
: JSON::null : JSON::null;
}
sub as_email {
defined($_[0]) && Bugzilla->user->in_group('editusers') ? $_[0] . '' : JSON::null;
} }
sub as_base64 { sub as_base64 {
...@@ -496,13 +501,9 @@ double value. If parameter is undefined, returns JSON::null. ...@@ -496,13 +501,9 @@ double value. If parameter is undefined, returns JSON::null.
=head2 as_email =head2 as_email
Takes an email address as a parameter if filters it if C<webservice_email_filter> is Takes an email address as a parameter. If the user is in the editusers group,
enabled in the system settings. If parameter is undefined, returns JSON::null. it returns the email address, unchanged. If the parameter is undefined or the
user is not in the editusers group, it returns JSON::null.
=head2 as_email_array
Similar to C<as_email>, but takes an array reference to a list of values and
returns an array reference with the converted values.
=head2 as_int =head2 as_int
...@@ -514,6 +515,18 @@ value. If parameter is undefined, returns JSON::null. ...@@ -514,6 +515,18 @@ value. If parameter is undefined, returns JSON::null.
Similar to C<as_int>, but takes an array reference to a list of values and Similar to C<as_int>, but takes an array reference to a list of values and
returns an array reference with the converted values. returns an array reference with the converted values.
=head2 as_login
Takes a login name as a parameter. If C<use_email_as_login> is enabled and the
user is logged out, it returns the local part of the email address (the part
before '@'). Else it returns the full login name. If parameter is undefined,
returns JSON::null.
=head2 as_login_array
Similar to C<as_login>, but takes an array reference to a list of values and
returns an array reference with the converted values.
=head2 as_name_array =head2 as_name_array
Takes a list of L<Bugzilla::Object> values and returns an array of new values Takes a list of L<Bugzilla::Object> values and returns an array of new values
......
...@@ -136,6 +136,10 @@ sub extern_id_used { ...@@ -136,6 +136,10 @@ sub extern_id_used {
|| $self->{_verifier}->extern_id_used; || $self->{_verifier}->extern_id_used;
} }
sub can_change_login {
return $_[0]->user_can_create_account;
}
sub can_change_email { sub can_change_email {
return $_[0]->user_can_create_account; return $_[0]->user_can_create_account;
} }
...@@ -412,6 +416,14 @@ Returns: C<true> if users are allowed to create new Bugzilla accounts, ...@@ -412,6 +416,14 @@ Returns: C<true> if users are allowed to create new Bugzilla accounts,
Description: Whether or not current login system uses extern_id. Description: Whether or not current login system uses extern_id.
=item C<can_change_login>
Description: Whether or not the current login system allows users to
change their own login.
Params: None
Returns: C<true> if users can change their own login,
C<false> otherwise.
=item C<can_change_email> =item C<can_change_email>
Description: Whether or not the current login system allows users to Description: Whether or not the current login system allows users to
......
...@@ -36,7 +36,8 @@ sub create_or_update_user { ...@@ -36,7 +36,8 @@ sub create_or_update_user {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $extern_id = $params->{extern_id}; my $extern_id = $params->{extern_id};
my $username = $params->{bz_username} || $params->{username}; my $login = $params->{bz_username} || $params->{username};
my $email = Bugzilla->params->{use_email_as_login} ? $login : $params->{email};
my $password = $params->{password} || '*'; my $password = $params->{password} || '*';
my $real_name = $params->{realname} || ''; my $real_name = $params->{realname} || '';
my $user_id = $params->{user_id}; my $user_id = $params->{user_id};
...@@ -44,7 +45,7 @@ sub create_or_update_user { ...@@ -44,7 +45,7 @@ sub create_or_update_user {
# A passed-in user_id always overrides anything else, for determining # A passed-in user_id always overrides anything else, for determining
# what account we should return. # what account we should return.
if (!$user_id) { if (!$user_id) {
my $username_user_id = login_to_id($username || ''); my $login_user_id = login_to_id($login || '');
my $extern_user_id; my $extern_user_id;
if ($extern_id) { if ($extern_id) {
trick_taint($extern_id); trick_taint($extern_id);
...@@ -52,26 +53,26 @@ sub create_or_update_user { ...@@ -52,26 +53,26 @@ sub create_or_update_user {
FROM profiles WHERE extern_id = ?', undef, $extern_id); FROM profiles WHERE extern_id = ?', undef, $extern_id);
} }
# If we have both a valid extern_id and a valid username, and they are # If we have both a valid extern_id and a valid login, and they are
# not the same id, then we have a conflict. # not the same id, then we have a conflict.
if ($username_user_id && $extern_user_id if ($login_user_id && $extern_user_id
&& $username_user_id ne $extern_user_id) && $login_user_id ne $extern_user_id)
{ {
my $extern_name = Bugzilla::User->new($extern_user_id)->login; my $extern_name = Bugzilla::User->new($extern_user_id)->login;
return { failure => AUTH_ERROR, error => "extern_id_conflict", return { failure => AUTH_ERROR, error => "extern_id_conflict",
details => {extern_id => $extern_id, details => {extern_id => $extern_id,
extern_user => $extern_name, extern_user => $extern_name,
username => $username} }; username => $login} };
} }
# If we have a valid username, but no valid id, # If we have a valid login, but no valid id,
# then we have to create the user. This happens when we're # then we have to create the user. This happens when we're
# passed only a username, and that username doesn't exist already. # passed only a login, and that login doesn't exist already.
if ($username && !$username_user_id && !$extern_user_id) { if ($login && !$login_user_id && !$extern_user_id) {
validate_email_syntax($username) validate_email_syntax($email)
|| return { failure => AUTH_ERROR, || return { failure => AUTH_ERROR,
error => 'auth_invalid_email', error => 'auth_invalid_email',
details => {addr => $username} }; details => {addr => $email} };
# Usually we'd call validate_password, but external authentication # Usually we'd call validate_password, but external authentication
# systems might follow different standards than ours. So in this # systems might follow different standards than ours. So in this
# place here, we call trick_taint without checks. # place here, we call trick_taint without checks.
...@@ -79,23 +80,24 @@ sub create_or_update_user { ...@@ -79,23 +80,24 @@ sub create_or_update_user {
# XXX Theoretically this could fail with an error, but the fix for # XXX Theoretically this could fail with an error, but the fix for
# that is too involved to be done right now. # that is too involved to be done right now.
my $user = Bugzilla::User->create({ my $user = Bugzilla::User->create({
login_name => $username, login_name => $login,
email => $email,
cryptpassword => $password, cryptpassword => $password,
realname => $real_name}); realname => $real_name});
$username_user_id = $user->id; $login_user_id = $user->id;
} }
# If we have a valid username id and an extern_id, but no valid # If we have a valid login id and an extern_id, but no valid
# extern_user_id, then we have to set the user's extern_id. # extern_user_id, then we have to set the user's extern_id.
if ($extern_id && $username_user_id && !$extern_user_id) { if ($extern_id && $login_user_id && !$extern_user_id) {
$dbh->do('UPDATE profiles SET extern_id = ? WHERE userid = ?', $dbh->do('UPDATE profiles SET extern_id = ? WHERE userid = ?',
undef, $extern_id, $username_user_id); undef, $extern_id, $login_user_id);
Bugzilla->memcached->clear({ table => 'profiles', id => $username_user_id }); Bugzilla->memcached->clear({ table => 'profiles', id => $login_user_id });
} }
# Finally, at this point, one of these will give us a valid user id. # Finally, at this point, one of these will give us a valid user id.
$user_id = $extern_user_id || $username_user_id; $user_id = $extern_user_id || $login_user_id;
} }
# If we still don't have a valid user_id, then we weren't passed # If we still don't have a valid user_id, then we weren't passed
...@@ -109,11 +111,15 @@ sub create_or_update_user { ...@@ -109,11 +111,15 @@ sub create_or_update_user {
# Now that we have a valid User, we need to see if any data has to be updated. # Now that we have a valid User, we need to see if any data has to be updated.
my $changed = 0; my $changed = 0;
if ($username && lc($user->login) ne lc($username)) { if ($email && lc($user->email) ne lc($email)) {
validate_email_syntax($username) validate_email_syntax($email)
|| return { failure => AUTH_ERROR, error => 'auth_invalid_email', || return { failure => AUTH_ERROR, error => 'auth_invalid_email',
details => {addr => $username} }; details => {addr => $email} };
$user->set_login($username); $user->set_email($email);
$changed = 1;
}
if ($login && lc($user->login) ne lc($login)) {
$user->set_login($login);
$changed = 1; $changed = 1;
} }
if ($real_name && $user->name ne $real_name) { if ($real_name && $user->name ne $real_name) {
......
...@@ -99,23 +99,21 @@ sub check_credentials { ...@@ -99,23 +99,21 @@ sub check_credentials {
my @emails = $user_entry->get_value($mail_attr); my @emails = $user_entry->get_value($mail_attr);
# Default to the first email address returned. # Default to the first email address returned.
$params->{bz_username} = $emails[0]; $params->{email} = $emails[0];
if (@emails > 1) { if (@emails > 1) {
# Cycle through the adresses and check if they're Bugzilla logins. # Cycle through the adresses and check if they're Bugzilla logins.
# Use the first one that returns a valid id. # Use the first one that returns a valid id.
foreach my $email (@emails) { foreach my $email (@emails) {
if ( login_to_id($email) ) { if ( email_to_id($email) ) {
$params->{bz_username} = $email; $params->{email} = $email;
last; last;
} }
} }
} }
} else {
$params->{bz_username} = $username;
} }
$params->{bz_username} = $username;
$params->{realname} ||= $user_entry->get_value("displayName"); $params->{realname} ||= $user_entry->get_value("displayName");
$params->{realname} ||= $user_entry->get_value("cn"); $params->{realname} ||= $user_entry->get_value("cn");
......
...@@ -46,8 +46,10 @@ sub check_credentials { ...@@ -46,8 +46,10 @@ sub check_credentials {
Bugzilla->params->{'RADIUS_NAS_IP'} || undef) Bugzilla->params->{'RADIUS_NAS_IP'} || undef)
|| return { failure => AUTH_LOGINFAILED }; || return { failure => AUTH_LOGINFAILED };
$params->{bz_username} = $username;
# Build the user account's e-mail address. # Build the user account's e-mail address.
$params->{bz_username} = $username . $address_suffix; $params->{email} = $username . $address_suffix;
return $params; return $params;
} }
......
...@@ -29,7 +29,10 @@ use File::Basename; ...@@ -29,7 +29,10 @@ use File::Basename;
# when it shouldn't # when it shouldn't
%Bugzilla::Config::EXPORT_TAGS = %Bugzilla::Config::EXPORT_TAGS =
( (
admin => [qw(update_params SetParam write_params)], admin => [qw(update_params
SetParam
call_param_onchange_handlers
write_params)],
); );
Exporter::export_ok_tags('admin'); Exporter::export_ok_tags('admin');
...@@ -78,7 +81,7 @@ sub param_panels { ...@@ -78,7 +81,7 @@ sub param_panels {
sub SetParam { sub SetParam {
my ($name, $value) = @_; my ($name, $value) = @_;
_load_params unless %params; _load_params() unless %params;
die "Unknown param $name" unless (exists $params{$name}); die "Unknown param $name" unless (exists $params{$name});
my $entry = $params{$name}; my $entry = $params{$name};
...@@ -96,6 +99,19 @@ sub SetParam { ...@@ -96,6 +99,19 @@ sub SetParam {
Bugzilla->params->{$name} = $value; Bugzilla->params->{$name} = $value;
} }
sub call_param_onchange_handlers {
my ($changes) = @_;
_load_params() unless %params;
foreach my $name (@$changes) {
my $param = $params{$name};
if (exists $param->{'onchange'}) {
$param->{'onchange'}->(Bugzilla->params->{$name});
}
}
}
sub update_params { sub update_params {
my ($params) = @_; my ($params) = @_;
my $answer = Bugzilla->installation_answers; my $answer = Bugzilla->installation_answers;
...@@ -211,7 +227,7 @@ sub update_params { ...@@ -211,7 +227,7 @@ sub update_params {
# --- DEFAULTS FOR NEW PARAMS --- # --- DEFAULTS FOR NEW PARAMS ---
_load_params unless %params; _load_params() unless %params;
foreach my $name (keys %params) { foreach my $name (keys %params) {
my $item = $params{$name}; my $item = $params{$name};
unless (exists $param->{$name}) { unless (exists $param->{$name}) {
...@@ -228,8 +244,10 @@ sub update_params { ...@@ -228,8 +244,10 @@ sub update_params {
} }
} }
# Bug 452525: OR based groups are on by default for new installations if ($new_install) {
$param->{'or_groups'} = 1 if $new_install; $param->{'or_groups'} = 1;
$param->{'use_email_as_login'} = 0;
}
# --- REMOVE OLD PARAMS --- # --- REMOVE OLD PARAMS ---
...@@ -341,6 +359,7 @@ Bugzilla::Config - Configuration parameters for Bugzilla ...@@ -341,6 +359,7 @@ Bugzilla::Config - Configuration parameters for Bugzilla
update_params(); update_params();
SetParam($param, $value); SetParam($param, $value);
call_param_onchange_handlers(\@changes);
write_params(); write_params();
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -371,6 +390,16 @@ Prints out information about what it's doing, if it makes any changes. ...@@ -371,6 +390,16 @@ Prints out information about what it's doing, if it makes any changes.
May prompt the user for input, if certain required parameters are not May prompt the user for input, if certain required parameters are not
specified. specified.
=item C<call_param_onchange_handlers(\@changes)>
Expects a list of parameter names.
For each parameter, checks whether there is a change handler defined,
and if so, calls it.
Params: C<\@changes> (required) - A list of parameter names.
Returns: nothing
=item C<write_params($params)> =item C<write_params($params)>
Description: Writes the parameters to disk. Description: Writes the parameters to disk.
......
...@@ -75,12 +75,6 @@ sub get_param_list { ...@@ -75,12 +75,6 @@ sub get_param_list {
}, },
{ {
name => 'webservice_email_filter',
type => 'b',
default => 0
},
{
name => 'emailregexp', name => 'emailregexp',
type => 't', type => 't',
default => q:^[\\w\\.\\+\\-=']+@[\\w\\.\\-]+\\.[\\w\\-]+$:, default => q:^[\\w\\.\\+\\-=']+@[\\w\\.\\-]+\\.[\\w\\-]+$:,
...@@ -95,9 +89,10 @@ sub get_param_list { ...@@ -95,9 +89,10 @@ sub get_param_list {
}, },
{ {
name => 'emailsuffix', name => 'use_email_as_login',
type => 't', type => 'b',
default => '' default => '1',
onchange => \&change_use_email_as_login
}, },
{ {
......
...@@ -38,7 +38,8 @@ sub get_param_list { ...@@ -38,7 +38,8 @@ sub get_param_list {
type => 's', type => 's',
choices => \@closed_bug_statuses, choices => \@closed_bug_statuses,
default => $closed_bug_statuses[0], default => $closed_bug_statuses[0],
checker => \&check_bug_status checker => \&check_bug_status,
onchange => \&change_duplicate_or_move_bug_status
}, },
{ {
......
...@@ -29,6 +29,8 @@ use parent qw(Exporter); ...@@ -29,6 +29,8 @@ use parent qw(Exporter);
check_bug_status check_smtp_auth check_theschwartz_available check_bug_status check_smtp_auth check_theschwartz_available
check_maxattachmentsize check_email check_smtp_ssl check_maxattachmentsize check_email check_smtp_ssl
check_comment_taggers_group check_smtp_server check_resolution check_comment_taggers_group check_smtp_server check_resolution
change_use_email_as_login change_duplicate_or_move_bug_status
); );
# Checking functions for the various values # Checking functions for the various values
...@@ -362,18 +364,36 @@ sub check_comment_taggers_group { ...@@ -362,18 +364,36 @@ sub check_comment_taggers_group {
return check_group($group_name); return check_group($group_name);
} }
# Change handler functions for various parameters
# If use_email_as_login is turned on, update all login names to be email
# addresses.
sub change_use_email_as_login {
my $newvalue = shift;
if ($newvalue) {
Bugzilla->dbh->do('UPDATE profiles SET login_name = email');
}
}
sub change_duplicate_or_move_bug_status {
my $newvalue = shift;
Bugzilla::Status::add_missing_bug_status_transitions($newvalue);
}
# OK, here are the parameter definitions themselves. # OK, here are the parameter definitions themselves.
# #
# Each definition is a hash with keys: # Each definition is a hash with keys:
# #
# name - name of the param # name - name of the param
# desc - description of the param (for editparams.cgi) # desc - description of the param (for editparams.cgi)
# type - see below # type - see below
# choices - (optional) see below # choices - (optional) see below
# default - default value for the param # default - default value for the param
# checker - (optional) checking function for validating parameter entry # checker - (optional) checking function for validating parameter entry.
# It is called with the value of the param as the first arg and a # It is called with the value of the param as the first arg
# reference to the param's hash as the second argument # and a reference to the param's hash as the second argument.
# onchange - (optional) handling function for parameter changes.
# The argument is the new value of the param.
# #
# The type value can be one of the following: # The type value can be one of the following:
# #
...@@ -467,6 +487,17 @@ Checks that the value is a valid regexp ...@@ -467,6 +487,17 @@ Checks that the value is a valid regexp
Checks that the required modules for comment tagging are installed, and that a Checks that the required modules for comment tagging are installed, and that a
valid group is provided. valid group is provided.
=item C<change_use_email_as_login>
Change handler for "use_email_as_login" parameter - if param is changed to
true, updates login_name field to be the value of the email field for all
users.
=item C<change_duplicate_or_move_bug_status>
Change handler for "duplicate_or_move_bug_status" parameter - if param is
changed, insert all missing transitions to the new bug status.
=back =back
=head1 B<Methods in need of POD> =head1 B<Methods in need of POD>
......
...@@ -930,6 +930,7 @@ use constant ABSTRACT_SCHEMA => { ...@@ -930,6 +930,7 @@ use constant ABSTRACT_SCHEMA => {
userid => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, userid => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1}, PRIMARYKEY => 1},
login_name => {TYPE => 'varchar(255)', NOTNULL => 1}, login_name => {TYPE => 'varchar(255)', NOTNULL => 1},
email => {TYPE => 'varchar(255)', NOTNULL => 1},
cryptpassword => {TYPE => 'varchar(128)'}, cryptpassword => {TYPE => 'varchar(128)'},
realname => {TYPE => 'varchar(255)', NOTNULL => 1, realname => {TYPE => 'varchar(255)', NOTNULL => 1,
DEFAULT => "''"}, DEFAULT => "''"},
...@@ -948,7 +949,9 @@ use constant ABSTRACT_SCHEMA => { ...@@ -948,7 +949,9 @@ use constant ABSTRACT_SCHEMA => {
profiles_login_name_idx => {FIELDS => ['login_name'], profiles_login_name_idx => {FIELDS => ['login_name'],
TYPE => 'UNIQUE'}, TYPE => 'UNIQUE'},
profiles_extern_id_idx => {FIELDS => ['extern_id'], profiles_extern_id_idx => {FIELDS => ['extern_id'],
TYPE => 'UNIQUE'} TYPE => 'UNIQUE'},
profiles_email_idx => {FIELDS => ['email'],
TYPE => 'UNIQUE'}
], ],
}, },
......
...@@ -301,8 +301,8 @@ sub _check_cc_list { ...@@ -301,8 +301,8 @@ sub _check_cc_list {
my @addresses = split(/[,\s]+/, $cc_list); my @addresses = split(/[,\s]+/, $cc_list);
my $addr_spec = $Email::Address::addr_spec; my $addr_spec = $Email::Address::addr_spec;
# We do not call check_email_syntax() because these addresses do not # We do not call check_email_syntax() because these addresses are not
# require to match 'emailregexp' and do not depend on 'emailsuffix'. # required to match 'emailregexp'.
foreach my $address (@addresses) { foreach my $address (@addresses) {
($address !~ /\P{ASCII}/ && $address =~ /^$addr_spec$/) ($address !~ /\P{ASCII}/ && $address =~ /^$addr_spec$/)
|| ThrowUserError('illegal_email_address', || ThrowUserError('illegal_email_address',
......
...@@ -322,7 +322,7 @@ sub _rederive_regexp { ...@@ -322,7 +322,7 @@ sub _rederive_regexp {
my ($self) = @_; my ($self) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $sth = $dbh->prepare("SELECT userid, login_name, group_id my $sth = $dbh->prepare("SELECT userid, email, group_id
FROM profiles FROM profiles
LEFT JOIN user_group_map LEFT JOIN user_group_map
ON user_group_map.user_id = profiles.userid ON user_group_map.user_id = profiles.userid
...@@ -337,8 +337,8 @@ sub _rederive_regexp { ...@@ -337,8 +337,8 @@ sub _rederive_regexp {
AND grant_type = ? and isbless = 0"); AND grant_type = ? and isbless = 0");
$sth->execute($self->id, GRANT_REGEXP); $sth->execute($self->id, GRANT_REGEXP);
my $regexp = $self->user_regexp; my $regexp = $self->user_regexp;
while (my ($uid, $login, $present) = $sth->fetchrow_array) { while (my ($uid, $email, $present) = $sth->fetchrow_array) {
if ($regexp ne '' and $login =~ /$regexp/i) { if ($regexp ne '' and $email =~ /$regexp/i) {
$sthadd->execute($uid, $self->id, GRANT_REGEXP) unless $present; $sthadd->execute($uid, $self->id, GRANT_REGEXP) unless $present;
} else { } else {
$sthdel->execute($uid, $self->id, GRANT_REGEXP) if $present; $sthdel->execute($uid, $self->id, GRANT_REGEXP) if $present;
......
...@@ -1631,10 +1631,14 @@ Params: ...@@ -1631,10 +1631,14 @@ Params:
=over =over
=item C<email>
The email address of the new account.
=item C<login> =item C<login>
The login of the new account. This is usually an email address, unless the The login of the new account. This will be the same as the email address if
C<emailsuffix> parameter is not empty. the "use_email_as_login" parameter is set, otherwise it may be different.
=back =back
......
...@@ -308,27 +308,47 @@ sub create_admin { ...@@ -308,27 +308,47 @@ sub create_admin {
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $admin_group = new Bugzilla::Group({ name => 'admin' }); my $admin_group = new Bugzilla::Group({ name => 'admin' });
my $admin_inheritors = my $admin_inheritors =
Bugzilla::Group->flatten_group_membership($admin_group->id); Bugzilla::Group->flatten_group_membership($admin_group->id);
my $admin_group_ids = join(',', @$admin_inheritors); my $admin_group_ids = join(',', @$admin_inheritors);
my ($admin_count) = $dbh->selectrow_array( my ($admin_count) = $dbh->selectrow_array(
"SELECT COUNT(*) FROM user_group_map "SELECT COUNT(*) FROM user_group_map
WHERE group_id IN ($admin_group_ids)"); WHERE group_id IN ($admin_group_ids)");
return if $admin_count; return if $admin_count;
my %answer = %{Bugzilla->installation_answers}; my %answer = %{Bugzilla->installation_answers};
my $login = $answer{'ADMIN_EMAIL'}; my $login = $answer{'ADMIN_LOGIN'};
my $email = $answer{'ADMIN_EMAIL'};
my $password = $answer{'ADMIN_PASSWORD'}; my $password = $answer{'ADMIN_PASSWORD'};
my $full_name = $answer{'ADMIN_REALNAME'}; my $full_name = $answer{'ADMIN_REALNAME'};
if (!$login || !$password || !$full_name) { if (!($login || Bugzilla->params->{'use_email_as_login'})
|| !$email
|| !$password)
{
say "\n" . get_text('install_admin_setup') . "\n"; say "\n" . get_text('install_admin_setup') . "\n";
} }
while (!$login) { while (!$email) {
print get_text('install_admin_get_email') . ' '; print get_text('install_admin_get_email') . ' ';
$email = <STDIN>;
chomp $email;
eval { Bugzilla::User->check_email($email); };
if ($@) {
say $@;
undef $email;
}
}
# Make sure the email address is used as login when required.
if (Bugzilla->params->{'use_email_as_login'}) {
$login = $email;
}
while (!$login) {
print get_text('install_admin_get_login') . ' ';
$login = <STDIN>; $login = <STDIN>;
chomp $login; chomp $login;
eval { Bugzilla::User->check_login_name($login); }; eval { Bugzilla::User->check_login_name($login); };
...@@ -349,7 +369,8 @@ sub create_admin { ...@@ -349,7 +369,8 @@ sub create_admin {
get_text('install_admin_get_password')); get_text('install_admin_get_password'));
} }
my $admin = Bugzilla::User->create({ login_name => $login, my $admin = Bugzilla::User->create({ login_name => $login,
email => $email,
realname => $full_name, realname => $full_name,
cryptpassword => $password }); cryptpassword => $password });
make_admin($admin); make_admin($admin);
......
...@@ -748,6 +748,10 @@ sub update_table_definitions { ...@@ -748,6 +748,10 @@ sub update_table_definitions {
# 2015-12-16 LpSolit@gmail.com - Bug 1232578 # 2015-12-16 LpSolit@gmail.com - Bug 1232578
_sanitize_audit_log_table(); _sanitize_audit_log_table();
# 2016-04-27 wurblzap@gmail.com and gerv@gerv.net - Bug 218917
# Split login_name into login_name and email columns
_split_login_and_email($old_params);
################################################################ ################################################################
# New --TABLE-- changes should go *** A B O V E *** this point # # New --TABLE-- changes should go *** A B O V E *** this point #
################################################################ ################################################################
...@@ -3957,6 +3961,27 @@ sub _sanitize_audit_log_table { ...@@ -3957,6 +3961,27 @@ sub _sanitize_audit_log_table {
} }
} }
sub _split_login_and_email {
my ($old_params) = (@_);
my $dbh = Bugzilla->dbh;
$dbh->bz_add_column('profiles', 'email',
{TYPE => 'varchar(255)', NOTNULL => 1}, '');
$dbh->do('UPDATE profiles SET email = login_name');
# This change obsoletes the 'emailsuffix' parameter. If it is in use,
# append it to all the values in the 'email' column.
my $suffix = $old_params->{'emailsuffix'};
if ($suffix) {
$dbh->do('UPDATE profiles SET email = ' . $dbh->sql_string_concat('email', '?'),
undef, $suffix);
}
$dbh->bz_add_index('profiles', 'profiles_email_idx',
{TYPE => 'UNIQUE', FIELDS => ['email']});
}
1; 1;
__END__ __END__
......
...@@ -1170,7 +1170,7 @@ sub create { ...@@ -1170,7 +1170,7 @@ sub create {
my $cache = Bugzilla->request_cache; my $cache = Bugzilla->request_cache;
return $cache->{login_not_email} //= return $cache->{login_not_email} //=
($params->{emailsuffix} (!$params->{use_email_as_login}
|| ($params->{user_verify_class} =~ /LDAP/ && $params->{LDAPmailattribute}) || ($params->{user_verify_class} =~ /LDAP/ && $params->{LDAPmailattribute})
|| ($params->{user_verify_class} =~ /RADIUS/ && $params->{RADIUS_email_suffix})) || ($params->{user_verify_class} =~ /RADIUS/ && $params->{RADIUS_email_suffix}))
? 1 : 0; ? 1 : 0;
......
...@@ -89,30 +89,32 @@ sub check_auth_delegation_token { ...@@ -89,30 +89,32 @@ sub check_auth_delegation_token {
# Creates and sends a token to create a new user account. # Creates and sends a token to create a new user account.
# It assumes that the login has the correct format and is not already in use. # It assumes that the login has the correct format and is not already in use.
sub issue_new_user_account_token { sub issue_new_user_account_token {
my $login_name = shift; my ($login, $email) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
# Is there already a pending request for this login name? If yes, do not throw # Is there already a pending request for this email? If yes, do not throw
# an error because the user may have lost their email with the token inside. # an error because the user may have lost their email with the token inside.
# But to prevent using this way to mailbomb an email address, make sure # But to prevent using this way to mailbomb an email address, make sure
# the last request is old enough before sending a new email (default: 10 minutes). # the last request is old enough before sending a new email (default: 10 minutes).
my $regexp = "^$email:";
my $pending_requests = $dbh->selectrow_array( my $pending_requests = $dbh->selectrow_array(
'SELECT COUNT(*) 'SELECT COUNT(*)
FROM tokens FROM tokens
WHERE tokentype = ? WHERE tokentype = ?
AND ' . $dbh->sql_istrcmp('eventdata', '?') . ' AND ' . $dbh->sql_regexp('eventdata', $dbh->quote($regexp)) . '
AND issuedate > ' AND issuedate > '
. $dbh->sql_date_math('NOW()', '-', ACCOUNT_CHANGE_INTERVAL, 'MINUTE'), . $dbh->sql_date_math('NOW()', '-', ACCOUNT_CHANGE_INTERVAL, 'MINUTE'),
undef, ('account', $login_name)); undef, 'account');
ThrowUserError('too_soon_for_new_token', {'type' => 'account'}) if $pending_requests; ThrowUserError('too_soon_for_new_token', {'type' => 'account'}) if $pending_requests;
my ($token, $token_ts) = _create_token(undef, 'account', $login_name); my ($token, $token_ts) = _create_token(undef, 'account', "$email:$login");
$vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'}; $vars->{'login'} = $login;
$vars->{'email'} = $email;
$vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400); $vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400);
$vars->{'token'} = $token; $vars->{'token'} = $token;
...@@ -131,15 +133,15 @@ sub IssueEmailChangeToken { ...@@ -131,15 +133,15 @@ sub IssueEmailChangeToken {
my $new_email = shift; my $new_email = shift;
my $user = Bugzilla->user; my $user = Bugzilla->user;
my ($token, $token_ts) = _create_token($user->id, 'emailold', $user->login . ":$new_email"); my ($token, $token_ts) = _create_token($user->id, 'emailold', $user->email . ":$new_email");
my $newtoken = _create_token($user->id, 'emailnew', $user->login . ":$new_email"); my $newtoken = _create_token($user->id, 'emailnew', $user->email . ":$new_email");
# Mail the user the token along with instructions for using it. # Mail the user the token along with instructions for using it.
my $template = Bugzilla->template_inner($user->setting('lang')); my $template = Bugzilla->template_inner($user->setting('lang'));
my $vars = {}; my $vars = {};
$vars->{'newemailaddress'} = $new_email . Bugzilla->params->{'emailsuffix'}; $vars->{'newemailaddress'} = $new_email;
$vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400); $vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400);
# First send an email to the new address. If this one doesn't exist, # First send an email to the new address. If this one doesn't exist,
...@@ -335,7 +337,17 @@ sub Cancel { ...@@ -335,7 +337,17 @@ sub Cancel {
# is no entry in the 'profiles' table. # is no entry in the 'profiles' table.
my $user = new Bugzilla::User($userid); my $user = new Bugzilla::User($userid);
$vars->{'emailaddress'} = $userid ? $user->email : $eventdata; if ($userid) {
$vars->{'emailaddress'} = $user->email;
$vars->{'login'} = $user->login;
}
else {
# Be careful! Some logins may contain ":" in them.
my ($email, $login) = split(':', $eventdata, 2);
$vars->{'emailaddress'} = $email;
$vars->{'login'} = $login;
}
$vars->{'remoteaddress'} = remote_ip(); $vars->{'remoteaddress'} = remote_ip();
$vars->{'token'} = $token; $vars->{'token'} = $token;
$vars->{'tokentype'} = $tokentype; $vars->{'tokentype'} = $tokentype;
...@@ -511,7 +523,7 @@ Bugzilla::Token - Provides different routines to manage tokens. ...@@ -511,7 +523,7 @@ Bugzilla::Token - Provides different routines to manage tokens.
use Bugzilla::Token; use Bugzilla::Token;
Bugzilla::Token::issue_new_user_account_token($login_name); Bugzilla::Token::issue_new_user_account_token($login, $email);
Bugzilla::Token::IssueEmailChangeToken($user, $new_email); Bugzilla::Token::IssueEmailChangeToken($user, $new_email);
Bugzilla::Token::IssuePasswordToken($user); Bugzilla::Token::IssuePasswordToken($user);
Bugzilla::Token::DeletePasswordTokens($user_id, $reason); Bugzilla::Token::DeletePasswordTokens($user_id, $reason);
...@@ -539,14 +551,15 @@ Bugzilla::Token - Provides different routines to manage tokens. ...@@ -539,14 +551,15 @@ Bugzilla::Token - Provides different routines to manage tokens.
Returns: The token. Returns: The token.
=item C<issue_new_user_account_token($login_name)> =item C<issue_new_user_account_token($login, $email)>
Description: Creates and sends a token per email to the email address Description: Creates and sends a token per email to the email address
requesting a new user account. It doesn't check whether requesting a new user account. It doesn't check whether
the user account already exists. The user will have to the user account already exists. The user will have to
use this token to confirm the creation of their user account. use this token to confirm the creation of their user account.
Params: $login_name - The new login name requested by the user. Params: $login - The new login name requested by the user.
$email - The email address to be associated with the account.
Returns: Nothing. It throws an error if the same user made the same Returns: Nothing. It throws an error if the same user made the same
request in the last few minutes. request in the last few minutes.
......
...@@ -690,9 +690,8 @@ sub generate_random_password { ...@@ -690,9 +690,8 @@ sub generate_random_password {
} }
sub validate_email_syntax { sub validate_email_syntax {
my ($addr) = @_; my ($email) = @_;
my $match = Bugzilla->params->{'emailregexp'}; my $match = Bugzilla->params->{'emailregexp'};
my $email = $addr . Bugzilla->params->{'emailsuffix'};
# This regexp follows RFC 2822 section 3.4.1. # This regexp follows RFC 2822 section 3.4.1.
my $addr_spec = $Email::Address::addr_spec; my $addr_spec = $Email::Address::addr_spec;
# RFC 2822 section 2.1 specifies that email addresses must # RFC 2822 section 2.1 specifies that email addresses must
...@@ -700,7 +699,7 @@ sub validate_email_syntax { ...@@ -700,7 +699,7 @@ sub validate_email_syntax {
# Email::Address::addr_spec doesn't enforce this. # Email::Address::addr_spec doesn't enforce this.
# We set the max length to 127 to ensure addresses aren't truncated when # We set the max length to 127 to ensure addresses aren't truncated when
# inserted into the tokens.eventdata field. # inserted into the tokens.eventdata field.
if ($addr =~ /$match/ if ($email =~ /$match/
&& $email !~ /\P{ASCII}/ && $email !~ /\P{ASCII}/
&& $email =~ /^$addr_spec$/ && $email =~ /^$addr_spec$/
&& length($email) <= 127) && length($email) <= 127)
...@@ -713,11 +712,10 @@ sub validate_email_syntax { ...@@ -713,11 +712,10 @@ sub validate_email_syntax {
} }
sub check_email_syntax { sub check_email_syntax {
my ($addr) = @_; my ($email) = @_;
unless (validate_email_syntax(@_)) { unless (validate_email_syntax(@_)) {
my $email = $addr . Bugzilla->params->{'emailsuffix'}; ThrowUserError('illegal_email_address', { email => $email });
ThrowUserError('illegal_email_address', { addr => $email });
} }
} }
......
...@@ -366,7 +366,7 @@ sub _translate_comment { ...@@ -366,7 +366,7 @@ sub _translate_comment {
my $comment_hash = { my $comment_hash = {
id => $self->type('int', $comment->id), id => $self->type('int', $comment->id),
bug_id => $self->type('int', $comment->bug_id), bug_id => $self->type('int', $comment->bug_id),
creator => $self->type('email', $comment->author->login), creator => $self->type('login', $comment->author->login),
time => $self->type('dateTime', $comment->creation_ts), time => $self->type('dateTime', $comment->creation_ts),
creation_time => $self->type('dateTime', $comment->creation_ts), creation_time => $self->type('dateTime', $comment->creation_ts),
is_private => $self->type('boolean', $comment->is_private), is_private => $self->type('boolean', $comment->is_private),
...@@ -1308,7 +1308,7 @@ sub _bug_to_hash { ...@@ -1308,7 +1308,7 @@ sub _bug_to_hash {
$item{alias} = [ map { $self->type('string', $_) } @{ $bug->alias } ]; $item{alias} = [ map { $self->type('string', $_) } @{ $bug->alias } ];
} }
if (filter_wants $params, 'assigned_to') { if (filter_wants $params, 'assigned_to') {
$item{'assigned_to'} = $self->type('email', $bug->assigned_to->login); $item{'assigned_to'} = $self->type('login', $bug->assigned_to->login);
$item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to'); $item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to');
} }
if (filter_wants $params, 'blocks') { if (filter_wants $params, 'blocks') {
...@@ -1322,7 +1322,7 @@ sub _bug_to_hash { ...@@ -1322,7 +1322,7 @@ sub _bug_to_hash {
$item{component} = $self->type('string', $bug->component); $item{component} = $self->type('string', $bug->component);
} }
if (filter_wants $params, 'cc') { if (filter_wants $params, 'cc') {
my @cc = map { $self->type('email', $_) } @{ $bug->cc }; my @cc = map { $self->type('login', $_) } @{ $bug->cc };
$item{'cc'} = \@cc; $item{'cc'} = \@cc;
$item{'cc_detail'} = [ map { $self->_user_to_hash($_, $params, undef, 'cc') } @{ $bug->cc_users } ]; $item{'cc_detail'} = [ map { $self->_user_to_hash($_, $params, undef, 'cc') } @{ $bug->cc_users } ];
} }
...@@ -1330,7 +1330,7 @@ sub _bug_to_hash { ...@@ -1330,7 +1330,7 @@ sub _bug_to_hash {
$item{'creation_time'} = $self->type('dateTime', $bug->creation_ts); $item{'creation_time'} = $self->type('dateTime', $bug->creation_ts);
} }
if (filter_wants $params, 'creator') { if (filter_wants $params, 'creator') {
$item{'creator'} = $self->type('email', $bug->reporter->login); $item{'creator'} = $self->type('login', $bug->reporter->login);
$item{'creator_detail'} = $self->_user_to_hash($bug->reporter, $params, undef, 'creator'); $item{'creator_detail'} = $self->_user_to_hash($bug->reporter, $params, undef, 'creator');
} }
if (filter_wants $params, 'depends_on') { if (filter_wants $params, 'depends_on') {
...@@ -1361,7 +1361,7 @@ sub _bug_to_hash { ...@@ -1361,7 +1361,7 @@ sub _bug_to_hash {
} }
if (filter_wants $params, 'qa_contact') { if (filter_wants $params, 'qa_contact') {
my $qa_login = $bug->qa_contact ? $bug->qa_contact->login : ''; my $qa_login = $bug->qa_contact ? $bug->qa_contact->login : '';
$item{'qa_contact'} = $self->type('email', $qa_login); $item{'qa_contact'} = $self->type('login', $qa_login);
if ($bug->qa_contact) { if ($bug->qa_contact) {
$item{'qa_contact_detail'} = $self->_user_to_hash($bug->qa_contact, $params, undef, 'qa_contact'); $item{'qa_contact_detail'} = $self->_user_to_hash($bug->qa_contact, $params, undef, 'qa_contact');
} }
...@@ -1433,8 +1433,7 @@ sub _user_to_hash { ...@@ -1433,8 +1433,7 @@ sub _user_to_hash {
my $item = filter $filters, { my $item = filter $filters, {
id => $self->type('int', $user->id), id => $self->type('int', $user->id),
real_name => $self->type('string', $user->name), real_name => $self->type('string', $user->name),
name => $self->type('email', $user->login), name => $self->type('login', $user->login),
email => $self->type('email', $user->email),
}, $types, $prefix; }, $types, $prefix;
return $item; return $item;
} }
...@@ -1455,10 +1454,10 @@ sub _attachment_to_hash { ...@@ -1455,10 +1454,10 @@ sub _attachment_to_hash {
is_patch => $self->type('int', $attach->ispatch), is_patch => $self->type('int', $attach->ispatch),
}, $types, $prefix; }, $types, $prefix;
# creator requires an extra lookup, so we only send them if # creator requires an extra lookup, so we only send it if
# the filter wants them. # the filter wants it.
if (filter_wants $filters, 'creator', $types, $prefix) { if (filter_wants $filters, 'creator', $types, $prefix) {
$item->{'creator'} = $self->type('email', $attach->attacher->login); $item->{'creator'} = $self->type('login', $attach->attacher->login);
} }
if (filter_wants $filters, 'data', $types, $prefix) { if (filter_wants $filters, 'data', $types, $prefix) {
...@@ -1490,7 +1489,7 @@ sub _flag_to_hash { ...@@ -1490,7 +1489,7 @@ sub _flag_to_hash {
foreach my $field (qw(setter requestee)) { foreach my $field (qw(setter requestee)) {
my $field_id = $field . "_id"; my $field_id = $field . "_id";
$item->{$field} = $self->type('email', $flag->$field->login) $item->{$field} = $self->type('login', $flag->$field->login)
if $flag->$field_id; if $flag->$field_id;
} }
...@@ -2575,10 +2574,6 @@ C<string> The 'real' name for this user, if any. ...@@ -2575,10 +2574,6 @@ C<string> The 'real' name for this user, if any.
C<string> The user's Bugzilla login. C<string> The user's Bugzilla login.
=item C<email>
C<string> The user's email address. Currently this is the same value as the name.
=back =back
=back =back
...@@ -2698,7 +2693,11 @@ in Bugzilla B<4.4>. ...@@ -2698,7 +2693,11 @@ in Bugzilla B<4.4>.
=item REST API call added in Bugzilla B<5.0>. =item REST API call added in Bugzilla B<5.0>.
=item In Bugzilla B<5.0>, the following items were added to the bugs return value: C<assigned_to_detail>, C<creator_detail>, C<qa_contact_detail>. =item In Bugzilla B<5.0>, the following items were added to the bugs return
value: C<assigned_to_detail>, C<creator_detail>, C<qa_contact_detail>.
=item Since Bugzilla B<6.0>, the email address of users is private and is no
longer returned as part of the user detail hash.
=back =back
......
...@@ -62,7 +62,6 @@ use constant PARAMETERS_LOGGED_IN => qw( ...@@ -62,7 +62,6 @@ use constant PARAMETERS_LOGGED_IN => qw(
defaultseverity defaultseverity
duplicate_or_move_bug_status duplicate_or_move_bug_status
emailregexpdesc emailregexpdesc
emailsuffix
letsubmitterchoosemilestone letsubmitterchoosemilestone
letsubmitterchoosepriority letsubmitterchoosepriority
mailfrom mailfrom
...@@ -75,6 +74,7 @@ use constant PARAMETERS_LOGGED_IN => qw( ...@@ -75,6 +74,7 @@ use constant PARAMETERS_LOGGED_IN => qw(
resolution_forbidden_with_open_blockers resolution_forbidden_with_open_blockers
search_allow_no_criteria search_allow_no_criteria
urlbase urlbase
use_email_as_login
use_see_also use_see_also
useclassification useclassification
usemenuforusers usemenuforusers
...@@ -417,7 +417,6 @@ A logged-in user can access the following parameters (listed alphabetically): ...@@ -417,7 +417,6 @@ A logged-in user can access the following parameters (listed alphabetically):
C<defaultseverity>, C<defaultseverity>,
C<duplicate_or_move_bug_status>, C<duplicate_or_move_bug_status>,
C<emailregexpdesc>, C<emailregexpdesc>,
C<emailsuffix>,
C<letsubmitterchoosemilestone>, C<letsubmitterchoosemilestone>,
C<letsubmitterchoosepriority>, C<letsubmitterchoosepriority>,
C<mailfrom>, C<mailfrom>,
...@@ -430,6 +429,7 @@ A logged-in user can access the following parameters (listed alphabetically): ...@@ -430,6 +429,7 @@ A logged-in user can access the following parameters (listed alphabetically):
C<resolution_forbidden_with_open_blockers>, C<resolution_forbidden_with_open_blockers>,
C<search_allow_no_criteria>, C<search_allow_no_criteria>,
C<urlbase>, C<urlbase>,
C<use_email_as_login>,
C<use_see_also>, C<use_see_also>,
C<useclassification>, C<useclassification>,
C<usemenuforusers>, C<usemenuforusers>,
......
...@@ -210,8 +210,8 @@ sub _get_group_membership { ...@@ -210,8 +210,8 @@ sub _get_group_membership {
map {{ map {{
id => $self->type('int', $_->id), id => $self->type('int', $_->id),
real_name => $self->type('string', $_->name), real_name => $self->type('string', $_->name),
name => $self->type('string', $_->login), name => $self->type('login', $_->login),
email => $self->type('string', $_->email), email => $self->type('email', $_->email),
can_login => $self->type('boolean', $_->is_enabled), can_login => $self->type('boolean', $_->is_enabled),
email_enabled => $self->type('boolean', $_->email_enabled), email_enabled => $self->type('boolean', $_->email_enabled),
login_denied_text => $self->type('string', $_->disabledtext), login_denied_text => $self->type('string', $_->disabledtext),
...@@ -282,7 +282,7 @@ name of the group. ...@@ -282,7 +282,7 @@ name of the group.
=item C<user_regexp> =item C<user_regexp>
C<string> A regular expression. Any user whose Bugzilla username matches C<string> A regular expression. Any user whose Bugzilla email address matches
this regular expression will automatically be granted membership in this group. this regular expression will automatically be granted membership in this group.
=item C<is_active> =item C<is_active>
...@@ -553,8 +553,7 @@ C<string> The email address of the user. ...@@ -553,8 +553,7 @@ C<string> The email address of the user.
=item name =item name
C<string> The login name of the user. Note that in some situations this is C<string> The login name of the user.
different than their email.
=item can_login =item can_login
......
...@@ -271,9 +271,9 @@ sub _component_to_hash { ...@@ -271,9 +271,9 @@ sub _component_to_hash {
description => description =>
$self->type('string' , $component->description), $self->type('string' , $component->description),
default_assigned_to => default_assigned_to =>
$self->type('email', $component->default_assignee->login), $self->type('login', $component->default_assignee->login),
default_qa_contact => default_qa_contact =>
$self->type('email', $component->default_qa_contact ? $self->type('login', $component->default_qa_contact ?
$component->default_qa_contact->login : ""), $component->default_qa_contact->login : ""),
sort_key => # sort_key is returned to match Bug.fields sort_key => # sort_key is returned to match Bug.fields
0, 0,
......
...@@ -222,8 +222,11 @@ sub type { ...@@ -222,8 +222,11 @@ sub type {
utf8::encode($value) if utf8::is_utf8($value); utf8::encode($value) if utf8::is_utf8($value);
$retval = encode_base64($value, ''); $retval = encode_base64($value, '');
} }
elsif ($type eq 'email' && Bugzilla->params->{'webservice_email_filter'}) { elsif ($type eq 'login') {
$retval = email_filter($value); $retval = Bugzilla->params->{'use_email_as_login'} ? email_filter($retval) : "$retval";
}
elsif ($type eq 'email') {
$retval = Bugzilla->user->in_group('editusers') ? "$retval" : '';
} }
return $retval; return $retval;
......
...@@ -35,11 +35,13 @@ BEGIN { ...@@ -35,11 +35,13 @@ BEGIN {
$value = Bugzilla::WebService::Server->datetime_format_outbound($value); $value = Bugzilla::WebService::Server->datetime_format_outbound($value);
$value =~ s/-//g; $value =~ s/-//g;
} }
elsif ($type eq 'login') {
$type = 'string';
$value = email_filter($value) if Bugzilla->params->{'use_email_as_login'};
}
elsif ($type eq 'email') { elsif ($type eq 'email') {
$type = 'string'; $type = 'string';
if (Bugzilla->params->{'webservice_email_filter'}) { $value = '' unless Bugzilla->user->in_group('editusers');
$value = email_filter($value);
}
} }
return XMLRPC::Data->type($type)->value($value); return XMLRPC::Data->type($type)->value($value);
}; };
......
...@@ -43,13 +43,11 @@ use constant PUBLIC_METHODS => qw( ...@@ -43,13 +43,11 @@ use constant PUBLIC_METHODS => qw(
); );
use constant MAPPED_FIELDS => { use constant MAPPED_FIELDS => {
email => 'login',
full_name => 'name', full_name => 'name',
login_denied_text => 'disabledtext', login_denied_text => 'disabledtext',
}; };
use constant MAPPED_RETURNS => { use constant MAPPED_RETURNS => {
login_name => 'email',
realname => 'full_name', realname => 'full_name',
disabledtext => 'login_denied_text', disabledtext => 'login_denied_text',
}; };
...@@ -67,7 +65,7 @@ sub login { ...@@ -67,7 +65,7 @@ sub login {
return $self->_login_to_hash($user); return $self->_login_to_hash($user);
} }
# Username and password params are required # Login name and password params are required
foreach my $param ("login", "password") { foreach my $param ("login", "password") {
(defined $params->{$param} || defined $params->{'Bugzilla_' . $param}) (defined $params->{$param} || defined $params->{'Bugzilla_' . $param})
|| ThrowCodeError('param_required', { param => $param }); || ThrowCodeError('param_required', { param => $param });
...@@ -103,8 +101,11 @@ sub offer_account_by_email { ...@@ -103,8 +101,11 @@ sub offer_account_by_email {
my $email = trim($params->{email}) my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' }); || ThrowCodeError('param_required', { param => 'email' });
my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
$login or ThrowCodeError('param_required', { param => 'login' });
Bugzilla->user->check_account_creation_enabled; Bugzilla->user->check_account_creation_enabled;
Bugzilla->user->check_and_send_account_creation_confirmation($email); Bugzilla->user->check_and_send_account_creation_confirmation($login, $email);
return undef; return undef;
} }
...@@ -119,11 +120,16 @@ sub create { ...@@ -119,11 +120,16 @@ sub create {
my $email = trim($params->{email}) my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' }); || ThrowCodeError('param_required', { param => 'email' });
my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
$login or ThrowCodeError('param_required', { param => 'login' });
my $realname = trim($params->{full_name}); my $realname = trim($params->{full_name});
my $password = trim($params->{password}) || '*'; my $password = trim($params->{password}) || '*';
my $user = Bugzilla::User->create({ my $user = Bugzilla::User->create({
login_name => $email, login_name => $login,
email => $email,
realname => $realname, realname => $realname,
cryptpassword => $password cryptpassword => $password
}); });
...@@ -170,7 +176,7 @@ sub get { ...@@ -170,7 +176,7 @@ sub get {
@users = map { filter $params, { @users = map { filter $params, {
id => $self->type('int', $_->id), id => $self->type('int', $_->id),
real_name => $self->type('string', $_->name), real_name => $self->type('string', $_->name),
name => $self->type('email', $_->login), name => $self->type('login', $_->login),
} } @$in_group; } } @$in_group;
return { users => \@users }; return { users => \@users };
...@@ -222,12 +228,12 @@ sub get { ...@@ -222,12 +228,12 @@ sub get {
my $user_info = filter $params, { my $user_info = filter $params, {
id => $self->type('int', $user->id), id => $self->type('int', $user->id),
real_name => $self->type('string', $user->name), real_name => $self->type('string', $user->name),
name => $self->type('email', $user->login), name => $self->type('login', $user->login),
email => $self->type('email', $user->email),
can_login => $self->type('boolean', $user->is_enabled ? 1 : 0), can_login => $self->type('boolean', $user->is_enabled ? 1 : 0),
}; };
if (Bugzilla->user->in_group('editusers')) { if (Bugzilla->user->in_group('editusers')) {
$user_info->{email} = $self->type('email', $user->email),
$user_info->{email_enabled} = $self->type('boolean', $user->email_enabled); $user_info->{email_enabled} = $self->type('boolean', $user->email_enabled);
$user_info->{login_denied_text} = $self->type('string', $user->disabledtext); $user_info->{login_denied_text} = $self->type('string', $user->disabledtext);
} }
...@@ -605,10 +611,15 @@ and real name. ...@@ -605,10 +611,15 @@ and real name.
This is the recommended way to create a Bugzilla account. This is the recommended way to create a Bugzilla account.
=item B<Param> =item B<Params>
=over =over
=item C<login> (string) - the login name for the new account.
If the installation has the C<use_email_as_login> parameter switched on, then
this parameter is ignored, and the value of the C<email> parameter will
be used as the login name for the new account.
=item C<email> (string) - the email to send the offer to. =item C<email> (string) - the email to send the offer to.
=back =back
...@@ -659,7 +670,12 @@ are the same as below. ...@@ -659,7 +670,12 @@ are the same as below.
=over =over
=item C<email> (string) - The email address for the new user. =item C<login> (string) - the login name for the new account.
If the installation has the C<use_email_as_login> parameter switched on, then
this parameter is ignored, and the value of the C<email> parameter will
be used as the login name for the new account.
=item C<email> (string) - The email address for the new account's user.
=item C<full_name> (string) B<Optional> - The user's full name. Will =item C<full_name> (string) B<Optional> - The user's full name. Will
be set to empty if not specified. be set to empty if not specified.
...@@ -675,7 +691,7 @@ resetting their password) or by the administrator. ...@@ -675,7 +691,7 @@ resetting their password) or by the administrator.
=item B<Returns> =item B<Returns>
A hash containing one item, C<id>, the numeric id of the user that was A hash containing one item, C<id>, the numeric id of the user account that was
created. created.
=item B<Errors> =item B<Errors>
...@@ -737,7 +753,7 @@ C<array> Contains ids of user to update. ...@@ -737,7 +753,7 @@ C<array> Contains ids of user to update.
=item C<names> =item C<names>
C<array> Contains email/login of user to update. C<array> Contains login name of user to update.
=item C<full_name> =item C<full_name>
...@@ -745,8 +761,10 @@ C<string> The new name of the user. ...@@ -745,8 +761,10 @@ C<string> The new name of the user.
=item C<email> =item C<email>
C<string> The email of the user. Note that email used to login to bugzilla. C<string> The email address of the user. It may be required that this is the
Also note that you can only update one user at a time when changing the same as the login name. If you send different values in that case, the results
are undefined.
Note that you can only update one user at a time when changing the
login name / email. (An error will be thrown if you try to update this field login name / email. (An error will be thrown if you try to update this field
for multiple users at once.) for multiple users at once.)
...@@ -967,8 +985,7 @@ C<string> The email address of the user. ...@@ -967,8 +985,7 @@ C<string> The email address of the user.
=item name =item name
C<string> The login name of the user. Note that in some situations this is C<string> The login name of the user.
different than their email.
=item can_login =item can_login
...@@ -1054,7 +1071,7 @@ C<string> The CGI parameters for the saved report. ...@@ -1054,7 +1071,7 @@ C<string> The CGI parameters for the saved report.
B<Note>: If you are not logged in to Bugzilla when you call this function, you B<Note>: If you are not logged in to Bugzilla when you call this function, you
will only be returned the C<id>, C<name>, and C<real_name> items. If you are will only be returned the C<id>, C<name>, and C<real_name> items. If you are
logged in and not in editusers group, you will only be returned the C<id>, C<name>, logged in and not in editusers group, you will only be returned the C<id>, C<name>,
C<real_name>, C<email>, C<can_login>, and C<groups> items. The groups returned are C<real_name>, C<can_login>, and C<groups> items. The groups returned are
filtered based on your permission to bless each group. filtered based on your permission to bless each group.
The C<saved_searches> and C<saved_reports> items are only returned if you are The C<saved_searches> and C<saved_reports> items are only returned if you are
querying your own account, even if you are in the editusers group. querying your own account, even if you are in the editusers group.
......
...@@ -909,11 +909,11 @@ if (!$user->in_group('editbugs')) { ...@@ -909,11 +909,11 @@ if (!$user->in_group('editbugs')) {
} }
my @bugowners = keys %$bugowners; my @bugowners = keys %$bugowners;
if (scalar(@bugowners) > 1 && $user->in_group('editbugs')) { if (scalar(@bugowners) > 1
my $suffix = Bugzilla->params->{'emailsuffix'}; && $user->in_group('editbugs')
map(s/$/$suffix/, @bugowners) if $suffix; && Bugzilla->params->{'use_email_as_login'})
my $bugowners = join(",", @bugowners); {
$vars->{'bugowners'} = $bugowners; $vars->{'bugowners'} = join(",", @bugowners);
} }
# Whether or not to split the column titles across two rows to make # Whether or not to split the column titles across two rows to make
......
...@@ -461,6 +461,7 @@ The format of that file is as follows: ...@@ -461,6 +461,7 @@ The format of that file is as follows:
(Any localconfig variable or parameter can be specified as above.) (Any localconfig variable or parameter can be specified as above.)
$answer{'ADMIN_LOGIN'} = 'myadmin';
$answer{'ADMIN_EMAIL'} = 'myadmin@mydomain.net'; $answer{'ADMIN_EMAIL'} = 'myadmin@mydomain.net';
$answer{'ADMIN_PASSWORD'} = 'fooey'; $answer{'ADMIN_PASSWORD'} = 'fooey';
$answer{'ADMIN_REALNAME'} = 'Joel Peshkin'; $answer{'ADMIN_REALNAME'} = 'Joel Peshkin';
......
...@@ -27,22 +27,25 @@ my $vars = { doc_section => 'using/creating-an-account.html' }; ...@@ -27,22 +27,25 @@ my $vars = { doc_section => 'using/creating-an-account.html' };
print $cgi->header(); print $cgi->header();
my $login = $cgi->param('login'); my $email = $cgi->param('email');
my $login = Bugzilla->params->{'use_email_as_login'} ? $email : $cgi->param('login');
my $request_new_password = $cgi->param('request_new_password'); my $request_new_password = $cgi->param('request_new_password');
if ($request_new_password) { if ($request_new_password) {
$template->process('account/request-new-password.html.tmpl', $vars) $template->process('account/request-new-password.html.tmpl', $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
elsif (defined($login)) { elsif ($email && $login) {
$user->check_account_creation_enabled; $user->check_account_creation_enabled;
# Check the hash token to make sure this user actually submitted # Check the hash token to make sure this user actually submitted
# the create account form. # the create account form.
my $token = $cgi->param('token'); my $token = $cgi->param('token');
check_hash_token($token, ['create_account']); check_hash_token($token, ['create_account']);
$user->check_and_send_account_creation_confirmation($login); $user->check_and_send_account_creation_confirmation($login, $email);
$vars->{'login'} = $login; $vars->{'login'} = $login;
$vars->{'email'} = $email;
$template->process("account/created.html.tmpl", $vars) $template->process("account/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -169,12 +169,6 @@ requirelogin ...@@ -169,12 +169,6 @@ requirelogin
If this option is set, all access to the system beyond the front page will If this option is set, all access to the system beyond the front page will
require a login. No anonymous users will be permitted. require a login. No anonymous users will be permitted.
webservice_email_filter
Filter email addresses returned by the WebService API depending on if the
user is logged in or not. This works similarly to how the web UI currently
filters email addresses. If requirelogin is enabled, then this parameter
has no effect as users must be logged in to use Bugzilla anyway.
emailregexp emailregexp
Defines the regular expression used to validate email addresses used for Defines the regular expression used to validate email addresses used for
login names. The default attempts to match fully qualified email addresses login names. The default attempts to match fully qualified email addresses
...@@ -186,12 +180,6 @@ emailregexpdesc ...@@ -186,12 +180,6 @@ emailregexpdesc
This description is shown to the user to explain which email addresses are This description is shown to the user to explain which email addresses are
allowed by the :param:`emailregexp` param. allowed by the :param:`emailregexp` param.
emailsuffix
This is a string to append to any email addresses when actually sending mail
to that address. It is useful if you have changed the :param:`emailregexp`
param to only allow local usernames, but you want the mail to be delivered
to username\@my.local.hostname.
createemailregexp createemailregexp
This defines the (case-insensitive) regexp to use for email addresses that This defines the (case-insensitive) regexp to use for email addresses that
are permitted to self-register. The default (:paramval:`.*`) permits any are permitted to self-register. The default (:paramval:`.*`) permits any
...@@ -499,9 +487,8 @@ address. The LDAP authentication builds on top of this scheme, rather ...@@ -499,9 +487,8 @@ address. The LDAP authentication builds on top of this scheme, rather
than replacing it. The initial log-in is done with a username and than replacing it. The initial log-in is done with a username and
password for the LDAP directory. Bugzilla tries to bind to LDAP using password for the LDAP directory. Bugzilla tries to bind to LDAP using
those credentials and, if successful, tries to map this account to a those credentials and, if successful, tries to map this account to a
Bugzilla account. If an LDAP mail attribute is defined, the value of this Bugzilla account. An LDAP mail attribute must be defined.
attribute is used; otherwise, the :param:`emailsuffix` parameter is appended to If an account for this address
the LDAP username to form a full email address. If an account for this address
already exists in the Bugzilla installation, it will log in to that account. already exists in the Bugzilla installation, it will log in to that account.
If no account for that email address exists, one is created at the time If no account for that email address exists, one is created at the time
of login. (In this case, Bugzilla will attempt to use the "displayName" of login. (In this case, Bugzilla will attempt to use the "displayName"
......
...@@ -27,9 +27,7 @@ will appear in the Administration page. ...@@ -27,9 +27,7 @@ will appear in the Administration page.
The first screen is a search form to search for existing user The first screen is a search form to search for existing user
accounts. You can run searches based either on the user ID, real accounts. You can run searches based either on the user ID, real
name or login name (i.e. the email address, or just the first part name, login name or email address. The search can be conducted
of the email address if the :param:`emailsuffix` parameter is set).
The search can be conducted
in different ways using the listbox to the right of the text entry in different ways using the listbox to the right of the text entry
box. You can match by case-insensitive substring (the default), box. You can match by case-insensitive substring (the default),
regular expression, a *reverse* regular expression regular expression, a *reverse* regular expression
...@@ -55,13 +53,15 @@ Modifying Users ...@@ -55,13 +53,15 @@ Modifying Users
Once you have found your user, you can change the following Once you have found your user, you can change the following
fields: fields:
- *Login Name*: - *Email Address*:
This is generally the user's full email address. However, if you This is the user's full email address. Unless you turn off the
have are using the :param:`emailsuffix` parameter, this may
just be the user's login name. Unless you turn off the
:param:`allowemailchange` parameter, users can change their :param:`allowemailchange` parameter, users can change their
login names themselves (to any valid email address). login names themselves (to any valid email address).
- *Login Name*:
This is the user's login name, if it is (or can be) different from their email
address (i.e. if the "use_email_as_login" parameter is switched off).
- *Real Name*: The user's real name. Note that - *Real Name*: The user's real name. Note that
Bugzilla does not require this to create an account. Bugzilla does not require this to create an account.
......
...@@ -251,8 +251,6 @@ name type description ...@@ -251,8 +251,6 @@ name type description
id int The user ID for this user. id int The user ID for this user.
real_name string The 'real' name for this user, if any. real_name string The 'real' name for this user, if any.
name string The user's Bugzilla login. name string The user's Bugzilla login.
email string The user's email address. Currently this is the same value as
the name.
========= ====== ============================================================== ========= ====== ==============================================================
Flag object: Flag object:
...@@ -291,6 +289,11 @@ field name in ``include_fields``. ...@@ -291,6 +289,11 @@ field name in ``include_fields``.
* 102 (Access Denied) * 102 (Access Denied)
You do not have access to the bug_id you specified. You do not have access to the bug_id you specified.
**History**
Since Bugzilla 6.0, the email address of users is private and is no longer
returned as part of the user object.
.. _rest_history: .. _rest_history:
Bug History Bug History
......
...@@ -178,7 +178,6 @@ Example response for authenticated user: ...@@ -178,7 +178,6 @@ Example response for authenticated user:
"defaultseverity" : "normal", "defaultseverity" : "normal",
"duplicate_or_move_bug_status" : "RESOLVED", "duplicate_or_move_bug_status" : "RESOLVED",
"emailregexp" : "^[\\w\\.\\+\\-=']+@[\\w\\.\\-]+\\.[\\w\\-]+$", "emailregexp" : "^[\\w\\.\\+\\-=']+@[\\w\\.\\-]+\\.[\\w\\-]+$",
"emailsuffix" : "",
"letsubmitterchoosemilestone" : "1", "letsubmitterchoosemilestone" : "1",
"letsubmitterchoosepriority" : "1", "letsubmitterchoosepriority" : "1",
"mailfrom" : "bugzilla-daemon@example.com", "mailfrom" : "bugzilla-daemon@example.com",
...@@ -214,7 +213,6 @@ A logged-in user can access the following parameters (listed alphabetically): ...@@ -214,7 +213,6 @@ A logged-in user can access the following parameters (listed alphabetically):
* defaultseverity * defaultseverity
* duplicate_or_move_bug_status * duplicate_or_move_bug_status
* emailregexpdesc * emailregexpdesc
* emailsuffix
* letsubmitterchoosemilestone * letsubmitterchoosemilestone
* letsubmitterchoosepriority * letsubmitterchoosepriority
* mailfrom * mailfrom
......
...@@ -142,6 +142,8 @@ to perform this action. ...@@ -142,6 +142,8 @@ to perform this action.
========== ====== ============================================================= ========== ====== =============================================================
name type description name type description
========== ====== ============================================================= ========== ====== =============================================================
**login** string The login name for the new user. Ignored if the
*use_email_as_login* parameter is true.
**email** string The email address for the new user. **email** string The email address for the new user.
full_name string The user's full name. Will be set to empty if not specified. full_name string The user's full name. Will be set to empty if not specified.
password string The password for the new user account, in plain text. It password string The password for the new user account, in plain text. It
...@@ -173,6 +175,10 @@ id int The numeric ID of the user that was created. ...@@ -173,6 +175,10 @@ id int The numeric ID of the user that was created.
The password specified is too short. (Usually, this means the The password specified is too short. (Usually, this means the
password is under three characters.) password is under three characters.)
**History**
The *login* parameter has been added in Bugzilla 6.0.
.. _rest_user_update: .. _rest_user_update:
Update User Update User
...@@ -203,8 +209,7 @@ login names using the ``ids`` or ``names`` parameters respectively. ...@@ -203,8 +209,7 @@ login names using the ``ids`` or ``names`` parameters respectively.
**ids** array Additional IDs of users to update. **ids** array Additional IDs of users to update.
**names** array Additional login names of users to update. **names** array Additional login names of users to update.
full_name string The new name of the user. full_name string The new name of the user.
email string The email of the user. Note that email used to email string The email of the user. Also note that you can only
login to bugzilla. Also note that you can only
update one user at a time when changing the login update one user at a time when changing the login
name / email. (An error will be thrown if you try to name / email. (An error will be thrown if you try to
update this field for multiple users at once.) update this field for multiple users at once.)
...@@ -357,8 +362,7 @@ id int The unique integer ID that Bugzilla uses to represen ...@@ -357,8 +362,7 @@ id int The unique integer ID that Bugzilla uses to represen
this will not change. this will not change.
real_name string The actual name of the user. May be blank. real_name string The actual name of the user. May be blank.
email string The email address of the user. email string The email address of the user.
name string The login name of the user. Note that in some name string The login name of the user.
situations this is different than their email.
can_login boolean A boolean value to indicate if the user can login can_login boolean A boolean value to indicate if the user can login
into bugzilla. into bugzilla.
email_enabled boolean A boolean value to indicate if bug-related mail will email_enabled boolean A boolean value to indicate if bug-related mail will
...@@ -404,7 +408,7 @@ query string The CGI parameters for the saved report. ...@@ -404,7 +408,7 @@ query string The CGI parameters for the saved report.
If you are not authenticated when you call this function, you will only be If you are not authenticated when you call this function, you will only be
returned the ``id``, ``name``, and ``real_name`` items. If you are authenticated returned the ``id``, ``name``, and ``real_name`` items. If you are authenticated
and not in 'editusers' group, you will only be returned the ``id``, ``name``, and not in 'editusers' group, you will only be returned the ``id``, ``name``,
``real_name``, ``email``, ``can_login``, and ``groups`` items. The groups ``real_name``, ``can_login``, and ``groups`` items. The groups
returned are filtered based on your permission to bless each group. The returned are filtered based on your permission to bless each group. The
``saved_searches`` and ``saved_reports`` items are only returned if you are ``saved_searches`` and ``saved_reports`` items are only returned if you are
querying your own account, even if you are in the editusers group. querying your own account, even if you are in the editusers group.
......
...@@ -303,7 +303,7 @@ if ($action eq 'remove_regexp') { ...@@ -303,7 +303,7 @@ if ($action eq 'remove_regexp') {
my @deleted; my @deleted;
foreach my $member (@$users) { foreach my $member (@$users) {
if ($regexp eq '' || $member->login =~ m/$regexp/i) { if ($regexp eq '' || $member->email =~ m/$regexp/i) {
$sth_delete->execute($member->id, $group->id); $sth_delete->execute($member->id, $group->id);
push(@deleted, $member); push(@deleted, $member);
} }
......
...@@ -135,12 +135,11 @@ if ($action eq 'save' && $current_module) { ...@@ -135,12 +135,11 @@ if ($action eq 'save' && $current_module) {
if (($name eq "shutdownhtml") && ($value ne "")) { if (($name eq "shutdownhtml") && ($value ne "")) {
$vars->{'shutdown_is_active'} = 1; $vars->{'shutdown_is_active'} = 1;
} }
if ($name eq 'duplicate_or_move_bug_status') {
Bugzilla::Status::add_missing_bug_status_transitions($value);
}
} }
} }
call_param_onchange_handlers(\@changes);
$vars->{'message'} = 'parameters_updated'; $vars->{'message'} = 'parameters_updated';
$vars->{'param_changed'} = \@changes; $vars->{'param_changed'} = \@changes;
......
...@@ -72,7 +72,7 @@ if ($action eq 'search') { ...@@ -72,7 +72,7 @@ if ($action eq 'search') {
my $grouprestrict = $cgi->param('grouprestrict') || '0'; my $grouprestrict = $cgi->param('grouprestrict') || '0';
# 0 = disabled only, 1 = enabled only, 2 = everyone # 0 = disabled only, 1 = enabled only, 2 = everyone
my $is_enabled = $cgi->param('is_enabled') // 2; my $is_enabled = $cgi->param('is_enabled') // 2;
my $query = 'SELECT DISTINCT userid, login_name, realname, is_enabled, ' . my $query = 'SELECT DISTINCT userid, login_name, email, realname, is_enabled, ' .
$dbh->sql_date_format('last_seen_date', '%Y-%m-%d') . ' AS last_seen_date ' . $dbh->sql_date_format('last_seen_date', '%Y-%m-%d') . ' AS last_seen_date ' .
'FROM profiles'; 'FROM profiles';
my @bindValues; my @bindValues;
...@@ -98,7 +98,8 @@ if ($action eq 'search') { ...@@ -98,7 +98,8 @@ if ($action eq 'search') {
}; };
$nextCondition = 'AND'; $nextCondition = 'AND';
} }
} else { }
else {
$visibleGroups = 1; $visibleGroups = 1;
if ($grouprestrict eq '1') { if ($grouprestrict eq '1') {
$query .= qq{, user_group_map AS ugm $query .= qq{, user_group_map AS ugm
...@@ -116,10 +117,10 @@ if ($action eq 'search') { ...@@ -116,10 +117,10 @@ if ($action eq 'search') {
$vars->{'users'} = {}; $vars->{'users'} = {};
} }
else { else {
# Handle selection by login name, real name, or userid. # Handle selection by login name, email, real name, or userid.
if (defined($matchtype)) { if (defined($matchtype)) {
$query .= " $nextCondition "; $query .= " $nextCondition ";
my $expr = ""; my $expr = '';
if ($matchvalue eq 'userid') { if ($matchvalue eq 'userid') {
if ($matchstr) { if ($matchstr) {
my $stored_matchstr = $matchstr; my $stored_matchstr = $matchstr;
...@@ -127,6 +128,8 @@ if ($action eq 'search') { ...@@ -127,6 +128,8 @@ if ($action eq 'search') {
|| ThrowUserError('illegal_user_id', {userid => $stored_matchstr}); || ThrowUserError('illegal_user_id', {userid => $stored_matchstr});
} }
$expr = "profiles.userid"; $expr = "profiles.userid";
} elsif ($matchvalue eq 'email') {
$expr = 'profiles.email';
} elsif ($matchvalue eq 'realname') { } elsif ($matchvalue eq 'realname') {
$expr = "profiles.realname"; $expr = "profiles.realname";
} else { } else {
...@@ -182,7 +185,8 @@ if ($action eq 'search') { ...@@ -182,7 +185,8 @@ if ($action eq 'search') {
my $match_user_id = $vars->{'users'}[0]->{'userid'}; my $match_user_id = $vars->{'users'}[0]->{'userid'};
my $match_user = check_user($match_user_id); my $match_user = check_user($match_user_id);
edit_processing($match_user); edit_processing($match_user);
} else { }
else {
$template->process('admin/users/list.html.tmpl', $vars) $template->process('admin/users/list.html.tmpl', $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
...@@ -211,8 +215,14 @@ if ($action eq 'search') { ...@@ -211,8 +215,14 @@ if ($action eq 'search') {
my $password = $cgi->param('password'); my $password = $cgi->param('password');
$password = '*' if !defined $password; $password = '*' if !defined $password;
my $login_name = $cgi->param('login');
my $email = $cgi->param('email');
$login_name = $email if Bugzilla->params->{use_email_as_login};
my $new_user = Bugzilla::User->create({ my $new_user = Bugzilla::User->create({
login_name => scalar $cgi->param('login'), login_name => $login_name,
email => $email,
cryptpassword => $password, cryptpassword => $password,
realname => scalar $cgi->param('name'), realname => scalar $cgi->param('name'),
disabledtext => scalar $cgi->param('disabledtext'), disabledtext => scalar $cgi->param('disabledtext'),
...@@ -268,7 +278,9 @@ if ($action eq 'search') { ...@@ -268,7 +278,9 @@ if ($action eq 'search') {
# is not authorized. # is not authorized.
my $changes = {}; my $changes = {};
if ($editusers) { if ($editusers) {
$otherUser->set_login(scalar $cgi->param('login')); $otherUser->set_login(scalar $cgi->param('login'))
unless Bugzilla->params->{use_email_as_login};
$otherUser->set_email(scalar $cgi->param('email'));
$otherUser->set_name(scalar $cgi->param('name')); $otherUser->set_name(scalar $cgi->param('name'));
$otherUser->set_password(scalar $cgi->param('password')) $otherUser->set_password(scalar $cgi->param('password'))
if $cgi->param('password'); if $cgi->param('password');
......
...@@ -508,10 +508,6 @@ Bugzilla::Hook::process('email_in_after_parse', { fields => $mail_fields }); ...@@ -508,10 +508,6 @@ Bugzilla::Hook::process('email_in_after_parse', { fields => $mail_fields });
my $attachments = delete $mail_fields->{'attachments'}; my $attachments = delete $mail_fields->{'attachments'};
my $username = $mail_fields->{'reporter'}; my $username = $mail_fields->{'reporter'};
# If emailsuffix is in use, we have to remove it from the email address.
if (my $suffix = Bugzilla->params->{'emailsuffix'}) {
$username =~ s/\Q$suffix\E$//i;
}
my $user = Bugzilla::User->check($username); my $user = Bugzilla::User->check($username);
Bugzilla->set_user($user); Bugzilla->set_user($user);
......
...@@ -746,7 +746,7 @@ sub _remove_votes { ...@@ -746,7 +746,7 @@ sub _remove_votes {
my $whopart = ($who) ? " AND votes.who = $who" : ""; my $whopart = ($who) ? " AND votes.who = $who" : "";
my $sth = $dbh->prepare("SELECT profiles.login_name, " . my $sth = $dbh->prepare("SELECT profiles.email, " .
"profiles.userid, votes.vote_count, " . "profiles.userid, votes.vote_count, " .
"products.votesperuser, products.maxvotesperbug " . "products.votesperuser, products.maxvotesperbug " .
"FROM profiles " . "FROM profiles " .
...@@ -756,8 +756,8 @@ sub _remove_votes { ...@@ -756,8 +756,8 @@ sub _remove_votes {
"WHERE votes.bug_id = ? " . $whopart); "WHERE votes.bug_id = ? " . $whopart);
$sth->execute($id); $sth->execute($id);
my @list; my @list;
while (my ($name, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = $sth->fetchrow_array()) { while (my ($email, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = $sth->fetchrow_array()) {
push(@list, [$name, $userid, $oldvotes, $votesperuser, $maxvotesperbug]); push(@list, [$email, $userid, $oldvotes, $votesperuser, $maxvotesperbug]);
} }
# @messages stores all emails which have to be sent, if any. # @messages stores all emails which have to be sent, if any.
...@@ -766,7 +766,7 @@ sub _remove_votes { ...@@ -766,7 +766,7 @@ sub _remove_votes {
if (scalar(@list)) { if (scalar(@list)) {
foreach my $ref (@list) { foreach my $ref (@list) {
my ($name, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = (@$ref); my ($email, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = (@$ref);
$maxvotesperbug = min($votesperuser, $maxvotesperbug); $maxvotesperbug = min($votesperuser, $maxvotesperbug);
...@@ -797,7 +797,7 @@ sub _remove_votes { ...@@ -797,7 +797,7 @@ sub _remove_votes {
# Now lets send the e-mail to alert the user to the fact that their votes have # Now lets send the e-mail to alert the user to the fact that their votes have
# been reduced or removed. # been reduced or removed.
my $vars = { my $vars = {
'to' => $name . Bugzilla->params->{'emailsuffix'}, 'to' => $email,
'bugid' => $id, 'bugid' => $id,
'reason' => $reason, 'reason' => $reason,
......
...@@ -645,7 +645,7 @@ DoubleCrossCheck("milestones", "product_id", "value", ...@@ -645,7 +645,7 @@ DoubleCrossCheck("milestones", "product_id", "value",
Status('profile_login_start'); Status('profile_login_start');
my $sth = $dbh->prepare(q{SELECT userid, login_name FROM profiles}); my $sth = $dbh->prepare(q{SELECT userid, email FROM profiles});
$sth->execute; $sth->execute;
while (my ($id, $email) = $sth->fetchrow_array) { while (my ($id, $email) = $sth->fetchrow_array) {
......
...@@ -530,6 +530,24 @@ input.requestee { ...@@ -530,6 +530,24 @@ input.requestee {
font-weight: bold; font-weight: bold;
} }
form.table_layout div {
margin-bottom: 0.4em;
}
form.table_layout label {
font-weight: bold;
width: 8em;
display: inline-block;
float: left;
text-align: right;
padding-right: 0.5em;
}
.flex {
display: flex;
flex-wrap: wrap;
}
.throw_error a:visited { .throw_error a:visited {
color: darkblue ; color: darkblue ;
} }
......
...@@ -66,7 +66,6 @@ foreach my $input (keys %email_strings) { ...@@ -66,7 +66,6 @@ foreach my $input (keys %email_strings) {
# validate_email_syntax. We need to override some parameters. # validate_email_syntax. We need to override some parameters.
my $params = Bugzilla->params; my $params = Bugzilla->params;
$params->{emailregexp} = '.*'; $params->{emailregexp} = '.*';
$params->{emailsuffix} = '';
my $ascii_email = 'admin@company.com'; my $ascii_email = 'admin@company.com';
# U+0430 returns the Cyrillic "а", which looks similar to the ASCII "a". # U+0430 returns the Cyrillic "а", which looks similar to the ASCII "a".
my $utf8_email = "\N{U+0430}dmin\@company.com"; my $utf8_email = "\N{U+0430}dmin\@company.com";
......
...@@ -161,7 +161,7 @@ sub directive_ok { ...@@ -161,7 +161,7 @@ sub directive_ok {
# Directives # Directives
return 1 if $directive =~ /^(IF|END|UNLESS|FOREACH|PROCESS|INCLUDE| return 1 if $directive =~ /^(IF|END|UNLESS|FOREACH|PROCESS|INCLUDE|
BLOCK|USE|ELSE|NEXT|LAST|DEFAULT| BLOCK|USE|ELSE|NEXT|LAST|DEFAULT|CALL|
ELSIF|SET|SWITCH|CASE|WHILE|RETURN|STOP| ELSIF|SET|SWITCH|CASE|WHILE|RETURN|STOP|
TRY|CATCH|FINAL|THROW|CLEAR|MACRO|FILTER)/x; TRY|CATCH|FINAL|THROW|CLEAR|MACRO|FILTER)/x;
......
...@@ -65,12 +65,8 @@ ...@@ -65,12 +65,8 @@
<form action="token.cgi" method="post" id="forgot_form[% qs_suffix %]" <form action="token.cgi" method="post" id="forgot_form[% qs_suffix %]"
class="mini_forgot bz_default_hidden"> class="mini_forgot bz_default_hidden">
<label for="login[% qs_suffix FILTER html %]">Login:</label> <label for="login[% qs_suffix FILTER html %]">Login:</label>
<input name="loginname" size="20" id="login[% qs_suffix FILTER html %]" required <input name="email" size="20" id="login[% qs_suffix FILTER html %]" required
[% IF login_not_email %] type="email" placeholder="Your Email Address">
placeholder="Your Login"
[% ELSE %]
type="email" placeholder="Your Email Address"
[% END %]>
<input id="forgot_button[% qs_suffix %]" value="Reset Password" <input id="forgot_button[% qs_suffix %]" value="Reset Password"
type="submit"> type="submit">
<input type="hidden" name="a" value="reqpw"> <input type="hidden" name="a" value="reqpw">
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
<td> <td>
<input id="Bugzilla_login" name="Bugzilla_login" <input id="Bugzilla_login" name="Bugzilla_login"
[%- ' type="email"' UNLESS login_not_email %] autofocus required> [%- ' type="email"' UNLESS login_not_email %] autofocus required>
[% Param('emailsuffix') FILTER html %]
</td> </td>
</tr> </tr>
......
...@@ -21,7 +21,7 @@ to [% Param('maintainer') %] if you suspect foul play. ...@@ -21,7 +21,7 @@ to [% Param('maintainer') %] if you suspect foul play.
Token: [% token %] Token: [% token %]
Token Type: [% tokentype %] Token Type: [% tokentype %]
User: [% emailaddress %] User: [% login %]
Issue Date: [% issuedate FILTER time("%Y-%m-%d %H:%M:%S %Z", timezone) %] Issue Date: [% issuedate FILTER time("%Y-%m-%d %H:%M:%S %Z", timezone) %]
Event Data: [% eventdata %] Event Data: [% eventdata %]
Canceled Because: [% PROCESS cancelactionmessage %] Canceled Because: [% PROCESS cancelactionmessage %]
......
...@@ -6,25 +6,16 @@ ...@@ -6,25 +6,16 @@
# defined by the Mozilla Public License, v. 2.0. # defined by the Mozilla Public License, v. 2.0.
#%] #%]
[%# INTERFACE
# none
#
# Param("maintainer") is used to display the maintainer's email.
# Param("emailsuffix") is used to pre-fill the email field.
#%]
[% PROCESS global/header.html.tmpl [% PROCESS global/header.html.tmpl
title = "Create a new $terms.Bugzilla account" title = "Create a new $terms.Bugzilla account"
%] %]
<p> <p>
To create a [% terms.Bugzilla %] account, all you need to do is to enter To create a [% terms.Bugzilla %] account, all you need to do is to enter
[% IF Param('emailsuffix') == '' %] [% IF !Param('use_email_as_login') %]
a login name of your choice and
[% END %]
a legitimate email address. a legitimate email address.
[% ELSE %]
an account name which when combined with [% Param('emailsuffix') %]
corresponds to an address where you receive email.
[% END %]
You will receive an email at this address to confirm the creation of your You will receive an email at this address to confirm the creation of your
account. <b>You will not be able to log in until you receive the email.</b> account. <b>You will not be able to log in until you receive the email.</b>
If it doesn't arrive within a reasonable amount of time, you may contact If it doesn't arrive within a reasonable amount of time, you may contact
...@@ -32,50 +23,66 @@ ...@@ -32,50 +23,66 @@
at <a href="mailto:[% Param("maintainer") %]">[% Param("maintainer") %]</a>. at <a href="mailto:[% Param("maintainer") %]">[% Param("maintainer") %]</a>.
</p> </p>
[% IF Param('allowemailchange') %]
<p> <p>
If you already have an account and want to change your If you already have an account and want to change your
[% IF Param('emailsuffix') == '' %] [% IF Param('allowemailchange') %]
email address, email address or
[% ELSE %]
login name,
[% END %] [% END %]
you can change it from the Preferences page after logging in. login name, you can change it from the Preferences page after logging in.
</p> </p>
[% END %]
<p> <p>
A user account is required to report new [% terms.bugs %] or to comment into A user account is required to report new [% terms.bugs %] or to comment into
existing ones, as you may be contacted for more information if needed. existing ones, as you may be contacted for more information if needed.
This also lets other users clearly identify who is the author of comments This also lets other users clearly identify who is the author of comments
or changes made into [% terms.bugs %]. <b>Note that your email address will or changes made into [% terms.bugs %]. <b>Note that your email address will
<em>never</em> be displayed to logged out users. Only registered users will be <em>never</em> be displayed to
able to see it.</b> [% IF Param('use_email_as_login') %]
logged out users. Only registered users will be able to see it.</b>
[% ELSE %]
other users, unless you decide to use your email address as login. Only
your login is visible to other users.</b>
[% END %]
</p> </p>
[% IF Param('createemailregexp') == '.*' && Param('emailsuffix') == '' %] [% IF Param('createemailregexp') == '.*' %]
<p> <p>
<b>PRIVACY NOTICE:</b> [% terms.Bugzilla %] is an open [% terms.bug %] <b>PRIVACY NOTICE:</b> [% terms.Bugzilla %] is an open [% terms.bug %]
tracking system. Activity on most [% terms.bugs %], including email tracking system. Activity on most [% terms.bugs %] will be visible to
addresses, will be visible to registered users. We <b>recommend</b> using a registered users.
secondary account or free web email service (such as Gmail, Yahoo, [% IF Param('use_email_as_login') %]
Hotmail, or similar) to avoid receiving spam at your primary email address. That includes email addresses. We <b>recommend</b> using a
secondary account or free web email service (such as Gmail, Yahoo,
Hotmail, or similar) to avoid receiving spam at your primary email address.
[% END %]
</p> </p>
[% END %] [% END %]
<form id="account_creation_form" method="get" action="createaccount.cgi"> <form id="account_creation_form" action="createaccount.cgi" class="table_layout">
<span class="label"> [% IF !Param('use_email_as_login') %]
[% IF Param('emailsuffix') %] <div>
Login: <label for="login">Login</label>
[% ELSE %] <div class="flex">
Email address: <input size="35" id="login" name="login" autofocus required>
[% END %] <span class="bz_info">
</span> (no whitespaces and no @ character, unless it matches your email address)
<input size="35" id="login" name="login" autofocus </span>
[%- ' type="email"' UNLESS Param('emailsuffix') %] required> </div>
[% Param('emailsuffix') FILTER html %] </div>
<input type="hidden" id="token" name="token" value="[% issue_hash_token(['create_account']) FILTER html %]"> [% END %]
<input type="submit" id="send" value="Send">
<div>
<label for="email">Email Address</label>
<input size="35" id="email" name="email" type="email"
[%~ " autofocus" IF Param('use_email_as_login') %] required>
</div>
<div>
<label>&nbsp;</label>
<input type="hidden" id="token" name="token"
value="[% issue_hash_token(['create_account']) FILTER html %]">
<input type="submit" id="send" value="Send">
</div>
</form> </form>
[% PROCESS global/footer.html.tmpl %] [% PROCESS global/footer.html.tmpl %]
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# login: string. The user's Bugzilla login email address. # login: string. The user's Bugzilla login.
# email: string. The user's Bugzilla email address.
#%] #%]
[% title = BLOCK %] [% title = BLOCK %]
...@@ -17,9 +18,9 @@ ...@@ -17,9 +18,9 @@
[% PROCESS global/header.html.tmpl title = title %] [% PROCESS global/header.html.tmpl title = title %]
<p> <p>
A confirmation email has been sent containing a link to continue A confirmation email has been sent to <em>[% email FILTER html %]</em> containing
creating an account. The link will expire if an account is not a link to continue creating an account. The link will expire if an account is
created within [% constants.MAX_TOKEN_AGE FILTER html %] days. not created within [% constants.MAX_TOKEN_AGE FILTER html %] days.
</p> </p>
[% PROCESS global/footer.html.tmpl %] [% PROCESS global/footer.html.tmpl %]
...@@ -9,26 +9,40 @@ ...@@ -9,26 +9,40 @@
[%# INTERFACE: [%# INTERFACE:
# token: string. The token to be used in the user account creation. # token: string. The token to be used in the user account creation.
# email: email address of the user account. # email: email address of the user account.
# login: login of the user account.
# expiration_ts: expiration date of the token. # expiration_ts: expiration date of the token.
#%] #%]
[% title = BLOCK %]Create a new user account for '[% email FILTER html %]'[% END %] [% title = BLOCK %]Create a new user account for '[% login FILTER html %]'[% END %]
[% PROCESS "global/header.html.tmpl" [% PROCESS "global/header.html.tmpl" title = title %]
title = title
%]
[% password_complexity = Param('password_complexity') %] [% password_complexity = Param('password_complexity') %]
<p> <p>
To create your account, you must enter a password in the form below. To create your account, you must enter a password in the form below.
Your email address and Real Name (if provided) will be shown with Your real name is optional, but recommended.
changes you make.
</p> </p>
<form id="confirm_account_form" method="post" action="token.cgi"> <form id="confirm_account_form" method="post" action="token.cgi">
<input type="hidden" name="t" value="[% token FILTER html %]"> <input type="hidden" name="t" value="[% token FILTER html %]">
<input type="hidden" name="a" value="confirm_new_account"> <input type="hidden" name="a" value="confirm_new_account">
<table> <table>
[% IF !Param('use_email_as_login') %]
<tr>
<th>Login:</th>
<td>
[% IF login_already_in_use %]
<input id="login" name="login" required value="[% login FILTER html %]">
<span class="warning">
The login '[% login FILTER html %]' has been taken by another
user since you requested your account. Please choose another login.
</span>
[% ELSE %]
[% login FILTER html %]
[% END %]
</td>
</tr>
[% END %]
<tr> <tr>
<th>Email Address:</th> <th>Email Address:</th>
<td>[% email FILTER html %]</td> <td>[% email FILTER html %]</td>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
# token: random string used to authenticate the transaction. # token: random string used to authenticate the transaction.
# expiration_ts: expiration date of the token. # expiration_ts: expiration date of the token.
# email: email address of the new account. # email: email address of the new account.
# login: login name of the new account.
#%] #%]
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
...@@ -18,7 +19,7 @@ Subject: [% terms.Bugzilla %]: confirm account creation ...@@ -18,7 +19,7 @@ Subject: [% terms.Bugzilla %]: confirm account creation
X-Bugzilla-Type: admin X-Bugzilla-Type: admin
[%+ terms.Bugzilla %] has received a request to create a user account [%+ terms.Bugzilla %] has received a request to create a user account
using your email address ([% email %]). [%+ "($login)" IF !Param('use_email_as_login') %] using your email address ([% email %]).
To continue creating an account using this email address, visit the To continue creating an account using this email address, visit the
following link by [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %]: following link by [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %]:
...@@ -31,11 +32,14 @@ again by going to: ...@@ -31,11 +32,14 @@ again by going to:
[%+ urlbase %]createaccount.cgi [%+ urlbase %]createaccount.cgi
[% IF Param('createemailregexp') == '.*' && Param('emailsuffix') == '' %] [% IF Param('createemailregexp') == '.*' %]
PRIVACY NOTICE: [% terms.Bugzilla %] is an open [% terms.bug %] tracking system. Activity on most PRIVACY NOTICE: [% terms.Bugzilla %] is an open [% terms.bug %] tracking
[%+ terms.bugs %], including email addresses, will be visible to the public. We recommend system. Activity on most [%+ terms.bugs %] will be visible to the public.
using a secondary account or free web email service (such as Gmail, Yahoo, [% IF Param('use_email_as_login') %]
Hotmail, or similar) to avoid receiving spam at your primary email address. This includes email addresses. We recommend using a secondary account or free
web email service (such as Gmail, Yahoo, Hotmail, or similar) to avoid
receiving spam at your primary email address.
[% END %]
[% END %] [% END %]
If you do not wish to create an account, or if this request was made in If you do not wish to create an account, or if this request was made in
......
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# realname: string. The user's real name, if any. # email_change_date: string. The date the email change will be complete. (optional)
# login_change_date: string. The date the email change will be complete. (optional) # new_email: string. The user's new email address whilst not confirmed. (optional)
# new_login_name: string. The user's new Bugzilla login whilst not confirmed. (optional)
#%] #%]
<table> <table>
[% IF user.authorizer.can_change_password [% IF user.authorizer.can_change_password
|| (user.authorizer.can_change_email && Param('allowemailchange')) %] || (user.authorizer.can_change_email && Param('allowemailchange'))
|| user.authorizer.can_change_login %]
<tr> <tr>
<td colspan="3"> <td colspan="2">
Please enter your existing password to confirm account changes. Please enter your current password to confirm any changes in this section.
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
<input type="password" name="old_password" id="old_password"> <input type="password" name="old_password" id="old_password">
</td> </td>
</tr> </tr>
<tr>
<td colspan="2"><hr></td>
</tr>
[% END %] [% END %]
[% IF user.authorizer.can_change_password %] [% IF user.authorizer.can_change_password %]
...@@ -37,6 +34,9 @@ ...@@ -37,6 +34,9 @@
<th><label for="new_password1">New password:</label></th> <th><label for="new_password1">New password:</label></th>
<td> <td>
<input type="password" name="new_password1" id="new_password1"> <input type="password" name="new_password1" id="new_password1">
<span class="bz_info">
(Leave empty to keep current password)
</span>
</td> </td>
</tr> </tr>
...@@ -48,55 +48,75 @@ ...@@ -48,55 +48,75 @@
</tr> </tr>
[% END %] [% END %]
<tr> [% UNLESS Param('use_email_as_login') %]
<th> <tr>
<label for="realname">Your real name (optional, but encouraged):</label> <th><label for="new_login">Your login name:</label></th>
</th> <td>
<td> [% IF user.authorizer.can_change_login %]
<input size="35" name="realname" id="realname" value="[% realname FILTER html %]"> <input size="35" name="new_login" id="new_login"
</td> value="[% user.login FILTER html %]">
</tr> [% ELSE %]
[% user.login FILTER html %]
[% END %]
</td>
</tr>
[% END %]
[% IF user.authorizer.can_change_email && Param('allowemailchange') %] [% IF user.authorizer.can_change_email
[% IF login_change_date %] && Param('allowemailchange')
[% IF new_login_name %] && email_change_date %]
<tr> [% IF new_email %]
<th>Pending email address:</th> <tr>
<td>[% new_login_name FILTER html %]</td> <th><label>Pending email address:</label></th>
</tr> <td>[% new_email FILTER html %]</td>
<tr> </tr>
<th>Change request expires:</th> <tr>
<td>[% login_change_date FILTER time %]</td> <th><label>Change request expires:</label></th>
</tr> <td>[% email_change_date FILTER time %]</td>
[% ELSE %] </tr>
<tr>
<th>Confirmed email address:</th>
<td>[% user.login FILTER html %]</td>
</tr>
<tr>
<th>Completion date:</th>
<td>[% login_change_date FILTER time %]</td>
</tr>
[% END %]
[% ELSE %] [% ELSE %]
<tr> <tr>
<th> <th><label>Confirmed email address:</label></th>
<label for="new_login_name"> <td>[% user.email FILTER html %]</td>
[% IF Param('emailsuffix') %] </tr>
New login: <tr>
[% ELSE %] <th><label>Completion date:</label></th>
New email address: <td>[% email_change_date FILTER time %]</td>
[% END %]
</label>
</th>
<td>
<input size="35" id="new_login_name" name="new_login_name"
[%- ' type="email"' UNLESS Param('emailsuffix') %]>
</td>
</tr> </tr>
[% END %] [% END %]
[% ELSE %]
<tr>
<th>
<label for="new_email">
Your email address[% "/login" IF Param('use_email_as_login') %]:
</label>
</th>
<td>
[% IF user.authorizer.can_change_email && Param('allowemailchange') %]
<input size="35" name="new_email" id="new_email"
value="[% user.email FILTER html %]"
[%~ ' type="email"' IF Param('use_email_as_login') %]>
[% ELSE %]
[% user.email FILTER html %]
[% END %]
</td>
</tr>
[% END %] [% END %]
<tr>
<td colspan="2"><hr></td>
</tr>
<tr>
<th>
<label for="realname">Your real name (optional, but encouraged):</label>
</th>
<td>
<input size="35" name="realname" id="realname"
value="[% user.name FILTER html %]">
</td>
</tr>
[% Hook.process('field') %] [% Hook.process('field') %]
</table> </table>
...@@ -10,20 +10,14 @@ ...@@ -10,20 +10,14 @@
[% IF user.authorizer.can_change_password %] [% IF user.authorizer.can_change_password %]
<p> <p>
If you have an account, but have forgotten your password, enter your If you have an account, but have forgotten your password, enter your email
[% IF Param('emailsuffix') %] address below and submit a request to change your password. An email with
login name details on how to reset your password will be sent.
[% ELSE %]
email address
[% END %]
below and submit a request to change your password. An email with details
on how to reset your password will be sent.
</p> </p>
<form id="forgot_password" method="get" action="token.cgi"> <form id="forgot_password" method="get" action="token.cgi">
<input type="hidden" name="a" value="reqpw"> <input type="hidden" name="a" value="reqpw">
<input id="loginname" [% IF !Param('emailsuffix') %]type="email"[% END %] <input id="email" type="email" name="email" autofocus required>
name="loginname" autofocus required>
<input type="hidden" id="token" name="token" <input type="hidden" id="token" name="token"
value="[% issue_hash_token(['reqpw']) FILTER html %]"> value="[% issue_hash_token(['reqpw']) FILTER html %]">
<input type="submit" id="request" value="Reset Password"> <input type="submit" id="request" value="Reset Password">
......
...@@ -161,11 +161,7 @@ ...@@ -161,11 +161,7 @@
if requestable, who should get carbon copied on email notification of requests. if requestable, who should get carbon copied on email notification of requests.
This is a comma-separated list of full e-mail addresses which do not This is a comma-separated list of full e-mail addresses which do not
need to be [% terms.Bugzilla %] logins. need to be [% terms.Bugzilla %] logins.
[% IF Param('emailsuffix') %] <br>
Note that the configured emailsuffix
<kbd>[% Param('emailsuffix') %]</kbd> will <em>not</em> be appended
to these addresses, so you should add it explicitly if so desired.
[% END %]<br>
<input type="text" name="cc_list" value="[% type.cc_list FILTER html %]" size="80" <input type="text" name="cc_list" value="[% type.cc_list FILTER html %]" size="80"
maxlength="200" [%- ' disabled="disabled"' UNLESS can_fully_edit %]> maxlength="200" [%- ' disabled="disabled"' UNLESS can_fully_edit %]>
</td> </td>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#%] #%]
[% IF regexp %] [% IF regexp %]
[% title = "Confirm: Remove Explicit Members in the Regular Expression?" %] [% title = "Confirm: Remove Explicit Members Using A Regular Expression?" %]
[% ELSE %] [% ELSE %]
[% title = "Confirm: Remove All Explicit Members?" %] [% title = "Confirm: Remove All Explicit Members?" %]
[% END %] [% END %]
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
[% IF regexp %] [% IF regexp %]
<p>This option will remove all users from '[% group.name FILTER html %]' <p>This option will remove all users from '[% group.name FILTER html %]'
whose login names match the regular expression: whose email addresses match the regular expression:
'[% regexp FILTER html %]'</p> '[% regexp FILTER html %]'</p>
[% ELSE %] [% ELSE %]
<p>This option will remove all explicitly defined users <p>This option will remove all explicitly-added users
from '[% group.name FILTER html %].'</p> from '[% group.name FILTER html %].'</p>
[% END %] [% END %]
......
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
<form method="post" action="editgroups.cgi"> <form method="post" action="editgroups.cgi">
<fieldset id="mass-remove"> <fieldset id="mass-remove">
<legend>Remove all explicit memberships from users whose login names <legend>Remove all explicit memberships from users whose email addresses
match the following regular expression:</legend> match the following regular expression:</legend>
<input type="text" size="20" name="regexp"> <input type="text" size="20" name="regexp">
<input type="submit" id="remove-membership" value="Remove Memberships"> <input type="submit" id="remove-membership" value="Remove Memberships">
......
...@@ -93,29 +93,16 @@ ...@@ -93,29 +93,16 @@
"front page will require a login. No anonymous users will " _ "front page will require a login. No anonymous users will " _
"be permitted.", "be permitted.",
webservice_email_filter =>
"Filter email addresses returned by the WebService API depending on " _
"if the user is logged in or not. This works similarly to how the " _
"web UI currently filters email addresses. If <var>requirelogin</var> " _
"is enabled, then this parameter has no effect as users must be logged " _
"in to use Bugzilla.",
emailregexp => emailregexp =>
"This defines the regular expression to use for legal email addresses. " _ "This defines the regular expression to use for legal email addresses. " _
"The default tries to match fully qualified email addresses. " _ "The default tries to match fully qualified email addresses. " _
"Use <kbd>.*</kbd> to accept any email address following the " _ "Use <kbd>.*</kbd> to accept any email address following the " _
"<a href=\"http://tools.ietf.org/html/rfc2822#section-3.4.1\">RFC 2822</a> " _ "<a href=\"http://tools.ietf.org/html/rfc2822#section-3.4.1\">RFC 2822</a> " _
"specification. Another popular value to put here is <kbd>^[^@]+$</kbd>, " _ "specification.",
"which means 'local usernames, no @ allowed.'",
emailregexpdesc => "This description explains valid addresses that " _ emailregexpdesc => "This description explains valid addresses that " _
"are allowed by the <var>emailregexp</var> param.", "are allowed by the <var>emailregexp</var> param.",
emailsuffix => "This is a string to append to any email addresses when actually " _
"sending mail to that address. It is useful if you have changed " _
"the <var>emailregexp</var> param to only allow local usernames, " _
"but you want the mail to be delivered to username@my.local.hostname.",
createemailregexp => "This defines the (case-insensitive) regexp to use for email addresses that are " _ createemailregexp => "This defines the (case-insensitive) regexp to use for email addresses that are " _
"permitted to self-register using a 'New Account' feature. The " _ "permitted to self-register using a 'New Account' feature. The " _
"default (.*) permits any account matching the emailregexp " _ "default (.*) permits any account matching the emailregexp " _
...@@ -123,6 +110,13 @@ ...@@ -123,6 +110,13 @@
"will be permitted to create their own accounts and all accounts " _ "will be permitted to create their own accounts and all accounts " _
"will have to be created by an administrator.", "will have to be created by an administrator.",
use_email_as_login => "If switched on, users will log in with the email " _
"address of the account. If switched off, they will " _
"log in with a separate identifier.<br>" _
"<strong>Switching this from off to on results in " _
"the destructive act of the login name for all users " _
"being set to their email address!</strong>",
password_complexity => password_complexity =>
"Set the complexity required for passwords. In all cases must the passwords " _ "Set the complexity required for passwords. In all cases must the passwords " _
"be at least ${constants.USER_PASSWORD_MIN_LENGTH} characters long." _ "be at least ${constants.USER_PASSWORD_MIN_LENGTH} characters long." _
......
...@@ -35,10 +35,7 @@ ...@@ -35,10 +35,7 @@
LDAPmailattribute => "The name of the attribute of a user in your " _ LDAPmailattribute => "The name of the attribute of a user in your " _
"directory that contains the email address, to be " _ "directory that contains the email address, to be " _
"used as Bugzilla username. If this parameter " _ "used to send the user email.",
"is empty, Bugzilla will use the LDAP username"_
" as the Bugzilla username. You may also want" _
" to set the \"emailsuffix\" parameter, in this case.",
LDAPfilter => "LDAP filter to AND with the <var>LDAPuidattribute</var> for " _ LDAPfilter => "LDAP filter to AND with the <var>LDAPuidattribute</var> for " _
"filtering the list of valid users." } "filtering the list of valid users." }
......
...@@ -51,9 +51,15 @@ ...@@ -51,9 +51,15 @@
<th>Field</th> <th>Field</th>
<th>Value</th> <th>Value</th>
</tr> </tr>
[% IF !Param('use_email_as_login') %]
<tr>
<th>Login:</th>
<td>[% otheruser.login FILTER html %]</td>
</tr>
[% END %]
<tr> <tr>
<th>Login name:</th> <th>Email address:</th>
<td>[% otheruser.login FILTER html %]</td> <td>[% otheruser.email FILTER html %]</td>
</tr> </tr>
<tr> <tr>
<th>Real name:</th> <th>Real name:</th>
......
...@@ -27,35 +27,44 @@ ...@@ -27,35 +27,44 @@
[% listselectionurlparams = INCLUDE listselectionurlparams %] [% listselectionurlparams = INCLUDE listselectionurlparams %]
[% columns = [% columns =
[{name => 'login_name' [{name => 'login_name'
heading => 'Edit user...' heading => 'Edit user...'
contentlink => 'editusers.cgi?action=edit&amp;userid=%%userid%%' _ contentlink => 'editusers.cgi?action=edit&amp;userid=%%userid%%' _
listselectionurlparams listselectionurlparams
} },
{name => 'realname' {name => 'email'
heading => 'Real name' heading => 'Email address'
} },
{name => 'last_seen_date' {name => 'realname'
heading => 'Last Login' heading => 'Real name'
} },
{heading => 'Account History' {name => 'last_seen_date'
content => 'View' heading => 'Last Login'
contentlink => 'editusers.cgi?action=activity' _ },
'&amp;userid=%%userid%%' _ {name => 'view_history_link',
listselectionurlparams heading => 'Account History'
content => 'View'
contentlink => 'editusers.cgi?action=activity' _
'&amp;userid=%%userid%%' _
listselectionurlparams
},
{name => 'action_link',
heading => 'Action'
content => 'Delete'
contentlink => 'editusers.cgi?action=del' _
'&amp;userid=%%userid%%' _
listselectionurlparams
} }
] ]
%] %]
[%# Eliminate inappropriate columns, starting at the end %]
[% IF NOT (Param('allowuserdeletion') && editusers) %]
[% CALL columns.splice(5, 1) %]
[% END %]
[% IF Param('allowuserdeletion') && editusers %] [% IF Param('use_email_as_login') %]
[% columns.push({heading => 'Action' [% CALL columns.splice(1, 1) %]
content => 'Delete'
contentlink => 'editusers.cgi?action=del' _
'&amp;userid=%%userid%%' _
listselectionurlparams
}
)
%]
[% END %] [% END %]
[%# Disabled users are crossed out. Missing realnames are noticed in red. %] [%# Disabled users are crossed out. Missing realnames are noticed in red. %]
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<p><label for="matchvalue">List users with</label> <p><label for="matchvalue">List users with</label>
<select id="matchvalue" name="matchvalue"> <select id="matchvalue" name="matchvalue">
<option value="login_name">login name</option> <option value="login_name">login name</option>
<option value="email">email address</option>
<option value="realname">real name</option> <option value="realname">real name</option>
<option value="userid">user id</option> <option value="userid">user id</option>
</select> </select>
......
...@@ -17,13 +17,31 @@ ...@@ -17,13 +17,31 @@
var disable_mail_manually_set = [% (otheruser.email_disabled ? 1 : 0) FILTER js %]; var disable_mail_manually_set = [% (otheruser.email_disabled ? 1 : 0) FILTER js %];
</script> </script>
[% IF NOT Param('use_email_as_login') %]
<tr>
<th><label for="login">Login:</label></th>
<td>
[% IF editusers %]
<input size="64" maxlength="255" id="login" name="login"
value="[% otheruser.login FILTER html %]"
[%- " autofocus" UNLESS editform %] required>
[% ELSE %]
[% otheruser.login FILTER html %]
[% END %]
</td>
</tr>
[% END %]
<tr> <tr>
<th><label for="login">Login name:</label></th> <th>
<label for="email">
Email address [% ' (login)' IF Param('use_email_as_login') %]:
</label>
</th>
<td> <td>
[% IF editusers %] [% IF editusers %]
<input size="64" maxlength="255" id="login" name="login" <input size="64" maxlength="255" id="email" name="email"
value="[% otheruser.login FILTER html %]" value="[% otheruser.email FILTER html %]"
[%- " autofocus" UNLESS editform %] required> [%- " autofocus" IF Param('use_email_as_login') AND NOT editform %] required>
[% IF editform %] [% IF editform %]
[% IF !otheruser.in_group('bz_sudo_protect') %] [% IF !otheruser.in_group('bz_sudo_protect') %]
<br> <br>
...@@ -32,7 +50,7 @@ ...@@ -32,7 +50,7 @@
[% END %] [% END %]
[% END %] [% END %]
[% ELSE %] [% ELSE %]
[% otheruser.login FILTER html %] [% otheruser.email FILTER html %]
[% END %] [% END %]
</td> </td>
</tr> </tr>
......
...@@ -765,7 +765,7 @@ ...@@ -765,7 +765,7 @@
users users
[% END %] [% END %]
[% IF user.id %] [% IF user.id %]
[% IF bug.cc.contains( user.email ) %] [% IF bug.cc.contains( user.login ) %]
including you including you
[% END %] [% END %]
[% END %] [% END %]
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
%] %]
maintainer="[% Param('maintainer') FILTER xml %]" maintainer="[% Param('maintainer') FILTER xml %]"
[% IF user.id %] [% IF user.id %]
exporter="[% user.email FILTER email FILTER xml %]" exporter="[% user.login FILTER email FILTER xml %]"
[% END %] [% END %]
> >
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<type>[% a.contenttype FILTER xml %]</type> <type>[% a.contenttype FILTER xml %]</type>
<size>[% a.datasize FILTER xml %]</size> <size>[% a.datasize FILTER xml %]</size>
<attacher[% IF a.attacher.name != '' %] name="[% a.attacher.name FILTER xml %]"[% END -%]> <attacher[% IF a.attacher.name != '' %] name="[% a.attacher.name FILTER xml %]"[% END -%]>
[% a.attacher.email FILTER email FILTER xml %]</attacher> [% a.attacher.login FILTER email FILTER xml %]</attacher>
[%# This is here so automated clients can still use attachment.cgi %] [%# This is here so automated clients can still use attachment.cgi %]
[% IF displayfields.token && user.id %] [% IF displayfields.token && user.id %]
<token>[% issue_hash_token([a.id, a.modification_time]) FILTER xml %]</token> <token>[% issue_hash_token([a.id, a.modification_time]) FILTER xml %]</token>
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
[% IF field == 'reporter' OR field == 'assigned_to' OR [% IF field == 'reporter' OR field == 'assigned_to' OR
field == 'qa_contact' %] field == 'qa_contact' %]
[% name = val.name %] [% name = val.name %]
[% val = val.email FILTER email %] [% val = val.login FILTER email %]
[% ELSIF field == 'cc' %] [% ELSIF field == 'cc' %]
[% val = val FILTER email %] [% val = val FILTER email %]
[% ELSIF field == 'creation_ts' OR field == 'delta_ts' %] [% ELSIF field == 'creation_ts' OR field == 'delta_ts' %]
...@@ -134,9 +134,9 @@ ...@@ -134,9 +134,9 @@
id="[% flag.id FILTER xml %]" id="[% flag.id FILTER xml %]"
type_id="[% flag.type_id FILTER xml %]" type_id="[% flag.type_id FILTER xml %]"
status="[% flag.status FILTER xml %]" status="[% flag.status FILTER xml %]"
setter="[% flag.setter.email FILTER email FILTER xml %]" setter="[% flag.setter.login FILTER email FILTER xml %]"
[% IF flag.status == "?" && flag.requestee %] [% IF flag.status == "?" && flag.requestee %]
requestee="[% flag.requestee.email FILTER email FILTER xml %]" requestee="[% flag.requestee.login FILTER email FILTER xml %]"
[% END %] [% END %]
/> />
[% END %] [% END %]
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
[% IF c.is_about_attachment %] [% IF c.is_about_attachment %]
<attachid>[% c.extra_data FILTER xml %]</attachid> <attachid>[% c.extra_data FILTER xml %]</attachid>
[% END %] [% END %]
<who name="[% c.author.name FILTER xml %]">[% c.author.email FILTER email FILTER xml %]</who> <who name="[% c.author.name FILTER xml %]">[% c.author.login FILTER email FILTER xml %]</who>
<bug_when>[% c.creation_ts FILTER time("%Y-%m-%d %T %z") FILTER xml %]</bug_when> <bug_when>[% c.creation_ts FILTER time("%Y-%m-%d %T %z") FILTER xml %]</bug_when>
[% IF user.is_timetracker && (c.work_time - 0 != 0) %] [% IF user.is_timetracker && (c.work_time - 0 != 0) %]
<work_time>[% PROCESS formattimeunit time_unit = c.work_time FILTER xml %]</work_time> <work_time>[% PROCESS formattimeunit time_unit = c.work_time FILTER xml %]</work_time>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#%] #%]
From: [% Param("mailfrom") %] From: [% Param("mailfrom") %]
To: [% email %][% Param("emailsuffix") %] To: [% email %]
Subject: Your [% terms.Bugzilla %] [%+ terms.bug %] list needs attention. Subject: Your [% terms.Bugzilla %] [%+ terms.bug %] list needs attention.
X-Bugzilla-Type: whine X-Bugzilla-Type: whine
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
[% ELSIF message_tag == "account_creation_canceled" %] [% ELSIF message_tag == "account_creation_canceled" %]
[% title = "User Account Creation Canceled" %] [% title = "User Account Creation Canceled" %]
The creation of the user account [% account FILTER html %] has been The creation of the user account '[% login FILTER html %]' has been
canceled. canceled.
[% ELSIF message_tag == "account_updated" %] [% ELSIF message_tag == "account_updated" %]
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
<li> <li>
[% IF field == 'login_name' %] [% IF field == 'login_name' %]
The login is now [% otheruser.login FILTER html %]. The login is now [% otheruser.login FILTER html %].
[% ELSIF field == 'email' %]
The email is now [% otheruser.email FILTER html %].
[% ELSIF field == 'realname' %] [% ELSIF field == 'realname' %]
The real name has been updated. The real name has been updated.
[% ELSIF field == 'cryptpassword' %] [% ELSIF field == 'cryptpassword' %]
...@@ -89,8 +91,8 @@ ...@@ -89,8 +91,8 @@
successfully. successfully.
[% ELSIF message_tag == "account_disabled" %] [% ELSIF message_tag == "account_disabled" %]
Logging in with this user account [% account FILTER html %] is disabled, so Logging in with the user account with email address [% email FILTER html %]
you cannot change its password. is disabled, so you cannot change its password.
[% ELSIF message_tag == "attachment_creation_failed" %] [% ELSIF message_tag == "attachment_creation_failed" %]
The [% terms.bug %] was created successfully, but attachment creation The [% terms.bug %] was created successfully, but attachment creation
...@@ -496,7 +498,7 @@ ...@@ -496,7 +498,7 @@
[%+ terms.Bugzilla %]... [%+ terms.Bugzilla %]...
[% ELSIF message_tag == "migrate_user_created" %] [% ELSIF message_tag == "migrate_user_created" %]
User created: [% created.email FILTER html %] User created: [% created.login FILTER html %]
[% IF password %] Password: [% password FILTER html %][% END %] [% IF password %] Password: [% password FILTER html %][% END %]
[% ELSIF message_tag == "migrate_value_created" %] [% ELSIF message_tag == "migrate_value_created" %]
...@@ -506,6 +508,10 @@ ...@@ -506,6 +508,10 @@
[%+ field_descs.${field.name} FILTER html %] value [%+ field_descs.${field.name} FILTER html %] value
created: [% value FILTER html %] created: [% value FILTER html %]
[% ELSIF message_tag == "email_changed" %]
[% title = "Email Changed" %]
Your email address has been updated.
[% ELSIF message_tag == "milestone_created" %] [% ELSIF message_tag == "milestone_created" %]
[% title = "Milestone Created" %] [% title = "Milestone Created" %]
The milestone <em>[% milestone.name FILTER html %]</em> has been created. The milestone <em>[% milestone.name FILTER html %]</em> has been created.
...@@ -561,7 +567,7 @@ ...@@ -561,7 +567,7 @@
[% ELSIF message_tag == "password_change_request" %] [% ELSIF message_tag == "password_change_request" %]
[% title = "Request to Change Password" %] [% title = "Request to Change Password" %]
A token for changing your password has been emailed to A token for changing your password has been emailed to
<em>[% login_name FILTER html %]</em>. <em>[% email FILTER html %]</em>.
Follow the instructions in that email to change your password. Follow the instructions in that email to change your password.
[% ELSIF message_tag == "password_changed" %] [% ELSIF message_tag == "password_changed" %]
...@@ -639,6 +645,9 @@ ...@@ -639,6 +645,9 @@
[% title = BLOCK %]Flag Type '[% flag_type.name FILTER html %]' Deactivated[% END %] [% title = BLOCK %]Flag Type '[% flag_type.name FILTER html %]' Deactivated[% END %]
The flag type <em>[% flag_type.name FILTER html %]</em> has been deactivated. The flag type <em>[% flag_type.name FILTER html %]</em> has been deactivated.
[% ELSIF message_tag == "install_admin_get_login" %]
Enter the login name the administrator will log in with:
[% ELSIF message_tag == "install_admin_get_email" %] [% ELSIF message_tag == "install_admin_get_email" %]
Enter the e-mail address of the administrator: Enter the e-mail address of the administrator:
......
...@@ -55,10 +55,12 @@ ...@@ -55,10 +55,12 @@
[% ELSIF error == "account_exists" %] [% ELSIF error == "account_exists" %]
[% title = "Account Already Exists" %] [% title = "Account Already Exists" %]
There is already an account with There is already an account with
[% IF email %] [% IF login %]
the login name [% email FILTER html %]. the login name [% login FILTER html %].
[% ELSIF email %]
the email address [% email FILTER html %].
[% ELSE %] [% ELSE %]
that login name. that login name or email address.
[% END %] [% END %]
[% ELSIF error == "account_locked" %] [% ELSIF error == "account_locked" %]
...@@ -523,9 +525,18 @@ ...@@ -523,9 +525,18 @@
[% title = "Email Change Already In Progress" %] [% title = "Email Change Already In Progress" %]
Email change already in progress; please check your email. Email change already in progress; please check your email.
[% ELSIF error == "email_needed_for_password_change" %]
[% title = "Email Address Required" %]
You must enter an email address when requesting to change your password.
[% ELSIF error == "email_no_body" %] [% ELSIF error == "email_no_body" %]
Your message did not contain any text, as far as we could tell. Your message did not contain any text, as far as we could tell.
[% ELSIF error == "email_required" %]
[% title = "Email Address Required" %]
[% admindocslinks = {'useradmin.html' => 'User administration'} %]
You must enter an email address for the new user.
[% ELSIF error == "empty_group_description" %] [% ELSIF error == "empty_group_description" %]
[% title = "The group description cannot be empty" %] [% title = "The group description cannot be empty" %]
You must enter a description for the group. You must enter a description for the group.
...@@ -969,10 +980,10 @@ ...@@ -969,10 +980,10 @@
[% IF format %] [% IF format %]
Please use the format '<code>[% format FILTER html %]</code>'. Please use the format '<code>[% format FILTER html %]</code>'.
[% END %] [% END %]
[% ELSIF error == "illegal_email_address" %] [% ELSIF error == "illegal_email_address" %]
[% title = "Invalid Email Address" %] [% title = "Invalid Email Address" %]
The e-mail address you entered (<b>[% addr FILTER html %]</b>) The e-mail address you entered (<b>[% email FILTER html %]</b>)
didn't pass our syntax checking for a legal email address. didn't pass our syntax checking for a legal email address.
[% IF default %] [% IF default %]
A legal address must contain exactly one '@', A legal address must contain exactly one '@',
...@@ -1076,6 +1087,12 @@ ...@@ -1076,6 +1087,12 @@
[% title = "Invalid Dimensions" %] [% title = "Invalid Dimensions" %]
The width or height specified is not a positive integer. The width or height specified is not a positive integer.
[% ELSIF error == "invalid_email" %]
[% title = "Invalid Email Address" %]
The address <tt>[% email FILTER html %]</tt> is not a valid email address.
Either you misspelled it, or the person has not
registered for a [% terms.Bugzilla %] account.
[% ELSIF error == "invalid_format" %] [% ELSIF error == "invalid_format" %]
[% title = "Invalid Format" %] [% title = "Invalid Format" %]
The format "[% format FILTER html %]" is invalid (must be one of The format "[% format FILTER html %]" is invalid (must be one of
...@@ -1208,18 +1225,28 @@ ...@@ -1208,18 +1225,28 @@
[% ELSIF error == "keyword_blank_description" %] [% ELSIF error == "keyword_blank_description" %]
[% title = "Blank Keyword Description Not Allowed" %] [% title = "Blank Keyword Description Not Allowed" %]
You must enter a non-blank description for the keyword. You must enter a non-blank description for the keyword.
[% ELSIF error == "keyword_blank_name" %] [% ELSIF error == "keyword_blank_name" %]
[% title = "Blank Keyword Name Not Allowed" %] [% title = "Blank Keyword Name Not Allowed" %]
You must enter a non-blank name for the keyword. You must enter a non-blank name for the keyword.
[% ELSIF error == "keyword_invalid_name" %] [% ELSIF error == "keyword_invalid_name" %]
[% title = "Invalid Keyword Name" %] [% title = "Invalid Keyword Name" %]
You may not use commas or whitespace in a keyword name. You may not use commas or whitespace in a keyword name.
[% ELSIF error == "login_needed_for_password_change" %] [% ELSIF error == "login_at_sign_disallowed" %]
[% title = "Login Name Required" %] [% title = "Illegal Character in Login" %]
You must enter a login name when requesting to change your password. Login names may not contain the "@" sign unless you are setting your
login name to be identical to your email address.
[% ELSIF error == "login_change_during_email_change" %]
[% title = "Login Change Not Permitted" %]
You may not change your login name while you are in the middle of the
process of changing your email address.
[% ELSIF error == "login_illegal_character" %]
[% title = "Illegal Character In Login" %]
Login names are not allowed to contain space characters.
[% ELSIF error == "login_required_for_pronoun" %] [% ELSIF error == "login_required_for_pronoun" %]
[% title = "Login Name Required" %] [% title = "Login Name Required" %]
...@@ -1230,6 +1257,10 @@ ...@@ -1230,6 +1257,10 @@
[%# Used for non-web-based LOGIN_REQUIRED situations. %] [%# Used for non-web-based LOGIN_REQUIRED situations. %]
You must log in before using this part of [% terms.Bugzilla %]. You must log in before using this part of [% terms.Bugzilla %].
[% ELSIF error == "login_too_long" %]
[% title = "Login Too Long" %]
Your login name is too long. It cannot exceed 127 characters.
[% ELSIF error == "markdown_disabled" %] [% ELSIF error == "markdown_disabled" %]
Markdown feature is not enabled. Markdown feature is not enabled.
...@@ -1495,8 +1526,8 @@ ...@@ -1495,8 +1526,8 @@
You did not enter your current password correctly. You did not enter your current password correctly.
[% ELSIF error == "current_password_required" %] [% ELSIF error == "current_password_required" %]
[% title = "Old Password Required" %] [% title = "Current Password Required" %]
You must enter your old password to change your email address. You must enter your current password to edit your account.
[% ELSIF error == "password_change_requests_not_allowed" %] [% ELSIF error == "password_change_requests_not_allowed" %]
[% title = "Password Change Requests Not Allowed" %] [% title = "Password Change Requests Not Allowed" %]
...@@ -1511,7 +1542,7 @@ ...@@ -1511,7 +1542,7 @@
The password must be at least The password must be at least
[%+ constants.USER_PASSWORD_MIN_LENGTH FILTER html %] characters long. [%+ constants.USER_PASSWORD_MIN_LENGTH FILTER html %] characters long.
[% IF locked_user %] [% IF locked_user %]
You must <a href="token.cgi?a=reqpw&amp;loginname=[% locked_user.email FILTER uri %]&amp;token=[% issue_hash_token(['reqpw']) FILTER uri %]"> You must <a href="token.cgi?a=reqpw&amp;email=[% locked_user.email FILTER uri %]&amp;token=[% issue_hash_token(['reqpw']) FILTER uri %]">
request a new password</a> in order to log in again. request a new password</a> in order to log in again.
[% END %] [% END %]
...@@ -1532,7 +1563,7 @@ ...@@ -1532,7 +1563,7 @@
[% END %] [% END %]
</ul> </ul>
[% IF locked_user %] [% IF locked_user %]
You must <a href="token.cgi?a=reqpw&amp;loginname=[% locked_user.email FILTER uri %]&amp;token=[% issue_hash_token(['reqpw']) FILTER uri %]"> You must <a href="token.cgi?a=reqpw&amp;email=[% locked_user.email FILTER uri %]&amp;token=[% issue_hash_token(['reqpw']) FILTER uri %]">
request a new password</a> in order to log in again. request a new password</a> in order to log in again.
[% END %] [% END %]
......
...@@ -12,15 +12,19 @@ ...@@ -12,15 +12,19 @@
<span class="vcard"> <span class="vcard">
[% FILTER collapse %] [% FILTER collapse %]
[% IF user.id %] [% IF Param("use_email_as_login") %]
<a class="email" href="mailto:[% who.email FILTER html %]" [% IF user.id %]
title="[% who.identity FILTER html %]"> <a class="email" href="mailto:[% who.email FILTER html %]"
[%- END -%] title="[% who.identity FILTER html %]">
[% IF who.name %] [%- END -%]
<span class="fn">[% who.name FILTER html %]</span> [% IF who.name %]
<span class="fn">[% who.name FILTER html %]</span>
[% ELSE %]
[% who.login FILTER email FILTER html %]
[% END %]
[% '</a>' IF user.id %]
[% ELSE %] [% ELSE %]
[% who.login FILTER email FILTER html %] [% who.identity FILTER html %]
[% END %] [% END %]
[% '</a>' IF user.id %]
[% END %] [% END %]
</span> </span>
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
</p> </p>
<p> <p>
[% IF series.creator %] [% IF series.creator %]
This series has been created by <a href="mailto:[% series.creator.email FILTER html %]"> This series has been created by [% series.creator.login FILTER html %]
[% series.creator.email FILTER html %]</a>
[% ELSE %] [% ELSE %]
This series has been automatically created by Bugzilla This series has been automatically created by Bugzilla
[% END %] [% END %]
......
...@@ -33,8 +33,7 @@ ...@@ -33,8 +33,7 @@
<p> <p>
<b>Creator</b>: <b>Creator</b>:
[% IF default.creator %] [% IF default.creator %]
<a href="mailto:[% default.creator.email FILTER html %]"> [% default.creator.login FILTER html %]
[% default.creator.email FILTER html %]</a>
[% ELSE %] [% ELSE %]
(automatically created by Bugzilla) (automatically created by Bugzilla)
[% END %] [% END %]
......
...@@ -122,22 +122,22 @@ sub requestChangePassword { ...@@ -122,22 +122,22 @@ sub requestChangePassword {
my $token = $cgi->param('token'); my $token = $cgi->param('token');
check_hash_token($token, ['reqpw']); check_hash_token($token, ['reqpw']);
my $login_name = $cgi->param('loginname') my $email = $cgi->param('email')
or ThrowUserError("login_needed_for_password_change"); or ThrowUserError("email_needed_for_password_change");
check_email_syntax($login_name); my $userid = email_to_id($email, 'throw_error_if_not_exist');
my $user = new Bugzilla::User({ name => $login_name }); my $user = new Bugzilla::User($userid);
# Make sure the user account is active. # Make sure the user account is active.
if ($user && !$user->is_enabled) { if (!$user->is_enabled) {
ThrowUserError('account_disabled', ThrowUserError('account_disabled',
{disabled_reason => get_text('account_disabled', {account => $login_name})}); {disabled_reason => get_text('account_disabled', {email => $email})});
} }
Bugzilla::Token::IssuePasswordToken($user) if $user; Bugzilla::Token::IssuePasswordToken($user);
$vars->{'message'} = "password_change_request"; $vars->{'message'} = "password_change_request";
$vars->{'login_name'} = $login_name; $vars->{'email'} = $email;
print $cgi->header(); print $cgi->header();
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
...@@ -208,7 +208,7 @@ sub changeEmail { ...@@ -208,7 +208,7 @@ sub changeEmail {
my ($old_email, $new_email) = split(/:/,$eventdata); my ($old_email, $new_email) = split(/:/,$eventdata);
$dbh->bz_start_transaction(); $dbh->bz_start_transaction();
my $user = Bugzilla::User->check({ id => $userid }); my $user = Bugzilla::User->check({ id => $userid });
my $cgipassword = $cgi->param('password'); my $cgipassword = $cgi->param('password');
...@@ -218,14 +218,14 @@ sub changeEmail { ...@@ -218,14 +218,14 @@ sub changeEmail {
# The new email address should be available as this was # The new email address should be available as this was
# confirmed initially so cancel token if it is not still available # confirmed initially so cancel token if it is not still available
if (! is_available_username($new_email,$old_email)) { if (!is_available_email($new_email, $old_email)) {
$vars->{'email'} = $new_email; # Needed for Bugzilla::Token::Cancel's mail $vars->{'email'} = $new_email; # Needed for Bugzilla::Token::Cancel's mail
Bugzilla::Token::Cancel($token, "account_exists", $vars); Bugzilla::Token::Cancel($token, "account_exists", $vars);
ThrowUserError("account_exists", { email => $new_email } ); ThrowUserError("account_exists", { email => $new_email } );
} }
# Update the user's login name in the profiles table. # Update the user's email address in the profiles table.
$user->set_login($new_email); $user->set_email($new_email);
$user->update({ keep_session => 1, keep_tokens => 1 }); $user->update({ keep_session => 1, keep_tokens => 1 });
delete_token($token); delete_token($token);
$dbh->do(q{DELETE FROM tokens WHERE userid = ? $dbh->do(q{DELETE FROM tokens WHERE userid = ?
...@@ -256,8 +256,8 @@ sub cancelChangeEmail { ...@@ -256,8 +256,8 @@ sub cancelChangeEmail {
my $user = Bugzilla::User->check({ id => $userid }); my $user = Bugzilla::User->check({ id => $userid });
# check to see if it has been altered # check to see if it has been altered
if ($user->login ne $old_email) { if ($user->email ne $old_email) {
$user->set_login($old_email); $user->set_email($old_email);
$user->update({ keep_tokens => 1 }); $user->update({ keep_tokens => 1 });
$vars->{'message'} = "email_change_canceled_reinstated"; $vars->{'message'} = "email_change_canceled_reinstated";
...@@ -285,13 +285,20 @@ sub cancelChangeEmail { ...@@ -285,13 +285,20 @@ sub cancelChangeEmail {
} }
sub request_create_account { sub request_create_account {
my ($date, $login_name, $token) = @_; my ($date, $data, $token) = @_;
Bugzilla->user->check_account_creation_enabled; Bugzilla->user->check_account_creation_enabled;
$vars->{'token'} = $token; # Be careful! Some logins may contain ":" in them.
$vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'}; my ($email, $login) = split(':', $data, 2);
$vars->{'expiration_ts'} = ctime(str2time($date) + MAX_TOKEN_AGE * 86400); $vars = {
token => $token,
login => $login,
email => $email,
# Make sure nobody else chose this login meanwhile.
login_already_in_use => login_to_id($login) ? 1 : 0,
expiration_ts => ctime(str2time($date) + MAX_TOKEN_AGE * 86400)
};
print $cgi->header(); print $cgi->header();
$template->process('account/email/confirm-new.html.tmpl', $vars) $template->process('account/email/confirm-new.html.tmpl', $vars)
...@@ -299,7 +306,7 @@ sub request_create_account { ...@@ -299,7 +306,7 @@ sub request_create_account {
} }
sub confirm_create_account { sub confirm_create_account {
my ($login_name, $token) = @_; my ($data, $token) = @_;
Bugzilla->user->check_account_creation_enabled; Bugzilla->user->check_account_creation_enabled;
...@@ -308,8 +315,13 @@ sub confirm_create_account { ...@@ -308,8 +315,13 @@ sub confirm_create_account {
# Make sure that these never show up anywhere in the UI. # Make sure that these never show up anywhere in the UI.
$cgi->delete('passwd1', 'passwd2'); $cgi->delete('passwd1', 'passwd2');
# Be careful! Some logins may contain ":" in them.
my ($email, $login) = split(':', $data, 2);
$login = $cgi->param('login') if login_to_id($login);
my $otheruser = Bugzilla::User->create({ my $otheruser = Bugzilla::User->create({
login_name => $login_name, login_name => $login,
email => $email,
realname => scalar $cgi->param('realname'), realname => scalar $cgi->param('realname'),
cryptpassword => $password}); cryptpassword => $password});
...@@ -332,10 +344,11 @@ sub confirm_create_account { ...@@ -332,10 +344,11 @@ sub confirm_create_account {
} }
sub cancel_create_account { sub cancel_create_account {
my ($login_name, $token) = @_; my ($data, $token) = @_;
$vars->{'message'} = 'account_creation_canceled'; $vars->{'message'} = 'account_creation_canceled';
$vars->{'account'} = $login_name; # Be careful! Some logins may contain ":" in them.
($vars->{'email'}, $vars->{'login'}) = split(':', $data, 2);
Bugzilla::Token::Cancel($token, $vars->{'message'}); Bugzilla::Token::Cancel($token, $vars->{'message'});
print $cgi->header(); print $cgi->header();
......
...@@ -37,8 +37,6 @@ sub DoAccount { ...@@ -37,8 +37,6 @@ sub DoAccount {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user; my $user = Bugzilla->user;
$vars->{'realname'} = $user->name;
if (Bugzilla->params->{'allowemailchange'} if (Bugzilla->params->{'allowemailchange'}
&& $user->authorizer->can_change_email) && $user->authorizer->can_change_email)
{ {
...@@ -55,11 +53,11 @@ sub DoAccount { ...@@ -55,11 +53,11 @@ sub DoAccount {
ORDER BY tokentype ASC " . $dbh->sql_limit(1), undef, $user->id); ORDER BY tokentype ASC " . $dbh->sql_limit(1), undef, $user->id);
if (scalar(@token) > 0) { if (scalar(@token) > 0) {
my ($tokentype, $change_date, $eventdata) = @token; my ($tokentype, $change_date, $eventdata) = @token;
$vars->{'login_change_date'} = $change_date; $vars->{'email_change_date'} = $change_date;
if($tokentype eq 'emailnew') { if($tokentype eq 'emailnew') {
my ($oldemail,$newemail) = split(/:/,$eventdata); my ($oldemail,$newemail) = split(/:/,$eventdata);
$vars->{'new_login_name'} = $newemail; $vars->{'new_email'} = $newemail;
} }
} }
} }
...@@ -77,7 +75,8 @@ sub SaveAccount { ...@@ -77,7 +75,8 @@ sub SaveAccount {
my $verified_password; my $verified_password;
my $pwd1 = $cgi->param('new_password1'); my $pwd1 = $cgi->param('new_password1');
my $pwd2 = $cgi->param('new_password2'); my $pwd2 = $cgi->param('new_password2');
my $new_login_name = trim(scalar $cgi->param('new_login_name')); my $new_login = clean_text(scalar $cgi->param('new_login'));
my $new_email = clean_text(scalar $cgi->param('new_email'));
if ($user->authorizer->can_change_password if ($user->authorizer->can_change_password
&& ($pwd1 ne "" || $pwd2 ne "")) && ($pwd1 ne "" || $pwd2 ne ""))
...@@ -95,28 +94,47 @@ sub SaveAccount { ...@@ -95,28 +94,47 @@ sub SaveAccount {
} }
} }
# This is used only if email and login are separate
if ($user->authorizer->can_change_login
&& !Bugzilla->params->{"use_email_as_login"}
&& $new_login
&& $user->login ne $new_login)
{
$verified_password || $user->check_current_password($oldpassword);
if ($new_login =~ /@/ &&
$new_login ne $user->email)
{
ThrowUserError("login_at_sign_disallowed");
}
if (Bugzilla::Token::HasEmailChangeToken($user->id)) {
ThrowUserError("login_change_during_email_change");
}
$user->set_login($new_login);
}
# This is used for the single value if use_email_as_login is true, or for
# the email address otherwise.
if ($user->authorizer->can_change_email if ($user->authorizer->can_change_email
&& Bugzilla->params->{"allowemailchange"} && Bugzilla->params->{"allowemailchange"}
&& $new_login_name) && $new_email
&& $user->email ne $new_email)
{ {
if ($user->login ne $new_login_name) { $verified_password || $user->check_current_password($oldpassword);
$verified_password || $user->check_current_password($oldpassword);
# Block multiple email changes for the same user. # Block multiple email changes for the same user.
if (Bugzilla::Token::HasEmailChangeToken($user->id)) { if (Bugzilla::Token::HasEmailChangeToken($user->id)) {
ThrowUserError("email_change_in_progress"); ThrowUserError("email_change_in_progress");
} }
# Before changing an email address, confirm one does not exist. # Before changing to an email address, confirm it does not exist.
check_email_syntax($new_login_name); $user->check_email($new_email);
is_available_username($new_login_name)
|| ThrowUserError("account_exists", {email => $new_login_name});
$vars->{'email_token'} = Bugzilla::Token::IssueEmailChangeToken($new_login_name); $vars->{'email_token'} = Bugzilla::Token::IssueEmailChangeToken($new_email);
$vars->{'email_changes_saved'} = 1; $vars->{'email_changes_saved'} = 1;
}
} }
$user->set_name(scalar $cgi->param('realname')); $user->set_name(scalar $cgi->param('realname'));
$user->update({ keep_session => 1, keep_tokens => 1 }); $user->update({ keep_session => 1, keep_tokens => 1 });
$dbh->bz_commit_transaction; $dbh->bz_commit_transaction;
......
...@@ -47,28 +47,28 @@ my $slt_bugs = $dbh->selectall_arrayref($query, undef, 'CONFIRMED', 'NEW', ...@@ -47,28 +47,28 @@ my $slt_bugs = $dbh->selectall_arrayref($query, undef, 'CONFIRMED', 'NEW',
'REOPENED'); 'REOPENED');
foreach my $bug (@$slt_bugs) { foreach my $bug (@$slt_bugs) {
my ($id, $desc, $email) = @$bug; my ($id, $desc, $login) = @$bug;
if (!defined $bugs{$email}) { if (!defined $bugs{$login}) {
$bugs{$email} = []; $bugs{$login} = [];
} }
if (!defined $desc{$email}) { if (!defined $desc{$login}) {
$desc{$email} = []; $desc{$login} = [];
} }
push @{$bugs{$email}}, $id; push @{$bugs{$login}}, $id;
push @{$desc{$email}}, $desc; push @{$desc{$login}}, $desc;
} }
foreach my $email (sort (keys %bugs)) { foreach my $login (sort (keys %bugs)) {
my $user = new Bugzilla::User({name => $email}); my $user = new Bugzilla::User({name => $login});
next if $user->email_disabled; next if $user->email_disabled;
my $vars = {'email' => $email}; my $vars = {'email' => $user->email};
my @bugs = (); my @bugs = ();
foreach my $i (@{$bugs{$email}}) { foreach my $i (@{$bugs{$login}}) {
my $bug = {}; my $bug = {};
$bug->{'summary'} = shift(@{$desc{$email}}); $bug->{'summary'} = shift(@{$desc{$login}});
$bug->{'id'} = $i; $bug->{'id'} = $i;
push @bugs, $bug; push @bugs, $bug;
} }
...@@ -81,5 +81,5 @@ foreach my $email (sort (keys %bugs)) { ...@@ -81,5 +81,5 @@ foreach my $email (sort (keys %bugs)) {
MessageToMTA($msg); MessageToMTA($msg);
say "$email " . join(" ", @{$bugs{$email}}); say $user->email . " " . join(" ", @{$bugs{$login}});
} }
...@@ -20,8 +20,7 @@ my ($sel, $config) = get_selenium(); ...@@ -20,8 +20,7 @@ my ($sel, $config) = get_selenium();
log_in($sel, $config, 'admin'); log_in($sel, $config, 'admin');
set_parameters($sel, {"Administrative Policies" => {"allowuserdeletion-on" => undef}, set_parameters($sel, {"Administrative Policies" => {"allowuserdeletion-on" => undef},
"User Authentication" => {"createemailregexp" => {type => "text", value => '.*'}, "User Authentication" => {"createemailregexp" => {type => "text", value => '.*'}} });
"emailsuffix" => {type => "text", value => ''}} });
# Set the password complexity to MIXED LETTERS. # Set the password complexity to MIXED LETTERS.
# Password must contain at least one UPPER and one lowercase letter. # Password must contain at least one UPPER and one lowercase letter.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment