diff options
author | David Lawrence <dkl@mozilla.com> | 2014-11-12 17:38:10 +0100 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2014-11-12 17:38:10 +0100 |
commit | c0156f20dfd3f5bfa3a0e1c2b6ca0f2de34797a4 (patch) | |
tree | 7b63716e937d2a746a5e5c85ab49a56cb137eb28 /Bugzilla/WebService/User.pm | |
parent | ded5d29a6083d08350ddf78d05266872cc2e9bb7 (diff) | |
download | bugzilla-c0156f20dfd3f5bfa3a0e1c2b6ca0f2de34797a4.tar.gz bugzilla-c0156f20dfd3f5bfa3a0e1c2b6ca0f2de34797a4.tar.xz |
Bug 1001462: Bug.search causes error when using simple token auth and specifying 'token' instead of 'Bugzilla_token'
r=glob,a=glob
Diffstat (limited to 'Bugzilla/WebService/User.pm')
-rw-r--r-- | Bugzilla/WebService/User.pm | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index 4c8af7f6c..f3b8bf703 100644 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -53,27 +53,20 @@ use constant MAPPED_RETURNS => { sub login { my ($self, $params) = @_; + # Check to see if we are already logged in + my $user = Bugzilla->user; + if ($user->id) { + return $self->_login_to_hash($user); + } + # Username and password params are required foreach my $param ("login", "password") { - defined $params->{$param} + (defined $params->{$param} || defined $params->{'Bugzilla_' . $param}) || ThrowCodeError('param_required', { param => $param }); } - # Make sure the CGI user info class works if necessary. - my $input_params = Bugzilla->input_params; - $input_params->{'Bugzilla_login'} = $params->{login}; - $input_params->{'Bugzilla_password'} = $params->{password}; - $input_params->{'Bugzilla_restrictlogin'} = $params->{restrict_login}; - - my $user = Bugzilla->login(); - - my $result = { id => $self->type('int', $user->id) }; - - if ($user->{_login_token}) { - $result->{'token'} = $user->id . "-" . $user->{_login_token}; - } - - return $result; + $user = Bugzilla->login(); + return $self->_login_to_hash($user); } sub logout { @@ -409,6 +402,15 @@ sub _report_to_hash { return $item; } +sub _login_to_hash { + my ($self, $user) = @_; + my $item = { id => $self->type('int', $user->id) }; + if ($user->{_login_token}) { + $item->{'token'} = $user->id . "-" . $user->{_login_token}; + } + return $item; +} + 1; __END__ |