]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 908338 - Create a new webservice called User.valid_login that will verify if...
authorDave Lawrence <dlawrence@mozilla.com>
Tue, 27 Aug 2013 03:21:15 +0000 (23:21 -0400)
committerDave Lawrence <dlawrence@mozilla.com>
Tue, 27 Aug 2013 03:21:15 +0000 (23:21 -0400)
r=glob,a=sgreen

Bugzilla/WebService/Server/REST/Resources/User.pm
Bugzilla/WebService/User.pm

index 1f82f752d66654f85c0058a02620cc5c6eecc880..e2a2ea2609999ea8f35c9d5a70e8777acd1fdeba 100644 (file)
@@ -19,6 +19,11 @@ BEGIN {
 
 sub _rest_resources {
     my $rest_resources = [
+        qr{^/valid_login$}, {
+            GET => {
+                method => 'valid_login'
+            }
+        },
         qr{^/user$}, {
             GET  => {
                 method => 'get'
index 08c8120767d382f0728b260fa45c854bf268e2a7..44938a97a4502d5e2d7993a010c3450dc52ad9f1 100644 (file)
@@ -83,6 +83,17 @@ sub logout {
     return undef;
 }
 
+sub valid_login {
+    my ($self, $params) = @_;
+    defined $params->{login}
+        || ThrowCodeError('param_required', { param => 'login' });
+    Bugzilla->login();
+    if (Bugzilla->user->id && Bugzilla->user->login eq $params->{login}) {
+        return $self->type('boolean', 1);
+    }
+    return $self->type('boolean', 0);
+}
+
 #################
 # User Creation #
 #################
@@ -486,6 +497,50 @@ Log out the user. Does nothing if there is no user logged in.
 
 =back
 
+=head2 valid_login
+
+B<UNSTABLE>
+
+=over
+
+=item B<Description>
+
+This method will verify whether a client's cookies or current login
+token is still valid or have expired. A valid username must be provided
+as well that matches.
+
+=item B<Params>
+
+=over
+
+=item C<login>
+
+The login name that matches the provided cookies or token.
+
+=item C<token>
+
+(string) Persistent login token current being used for authentication (optional).
+Cookies passed by client will be used before the token if both provided.
+
+=back
+
+=item B<Returns>
+
+Returns true/false depending on if the current cookies or token are valid
+for the provided username.
+
+=item B<Errors> (none)
+
+=item B<History>
+
+=over
+
+=item Added in Bugzilla B<5.0>.
+
+=back
+
+=back
+
 =head1 Account Creation and Modification
 
 =head2 offer_account_by_email