Closed Bug 445885 Opened 16 years ago Closed 16 years ago

User.login should ThrowUserError when called with incorrect parameters

Categories

(Bugzilla :: WebService, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.0

People

(Reporter: dkl, Assigned: dkl)

References

Details

Attachments

(2 files, 3 obsolete files)

Currently when User.login() is called without parameters a userid of 0 is returned. Instead User.login() should throw an error stating the parameters that are required.
Patch adding ThrowUserError to User.login that is thrown with either username or password is missing from the params.

Please review.
Dave
Attachment #330175 - Flags: review?(mkanat)
Comment on attachment 330175 [details] [diff] [review]
Patch to throw error when proper params are not passed to User.login (v1)

Hmm, we should be more consistent and throw the normal param_missing (or whatever it's called) error that we throw from other functions.
Attachment #330175 - Flags: review?(mkanat) → review-
(In reply to comment #2)
> (From update of attachment 330175 [details] [diff] [review])
> Hmm, we should be more consistent and throw the normal param_missing (or
> whatever it's called) error that we throw from other functions.

I thought about that as well first, but then realized that if someone did not pass either username and password, the param_missing error only handles a single param at a time. 

I could alter the param_missing error to accept multiple params as a list and then update the other ThrowUserError instances to use the new structure. Sound okay?

Dave
New patch that reuses the 'param_required' error. It will fail when either login or password are missing or empty.

Please review.
Dave
Assignee: webservice → dkl
Attachment #330175 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #330266 - Flags: review?(mkanat)
Comment on attachment 330266 [details] [diff] [review]
Patch to throw error when proper params are not passed to User.login (v2)

>+        defined $params->{$param} && $params->{$param}

  Somebody could theoretically have a username of "0".

  Otherwise this looks fine.
Attachment #330266 - Flags: review?(mkanat) → review-
I will submit a new patch that just checks for defined variables and
not worry about their values.
New patch. In this one I am just checking for defined params and not whether they have actual values.

Please review
Dave
Attachment #330266 - Attachment is obsolete: true
Attachment #330411 - Flags: review?(mkanat)
Comment on attachment 330411 [details] [diff] [review]
Patch to throw error when proper params are not passed to User.login (v3)

Great.
Attachment #330411 - Flags: review?(mkanat) → review+
Flags: approval3.2+
Flags: approval+
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → Bugzilla 4.0
tip:
Checking in Bugzilla/WebService/User.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/WebService/User.pm,v  <--  User.pm
new revision: 1.11; previous revision: 1.10
done

3.2:
Checking in Bugzilla/WebService/User.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/WebService/User.pm,v  <--  User.pm
new revision: 1.6.2.1; previous revision: 1.6
done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Note that the patch v3 (which wouldn't pass tests anyway) is not the one which has been checked in (fortunately). First, ThrowCodeError() could never be reached, and secondly it should have been ThrowUserError(). But the patch which has been checked in is fine, so all is fine. :) Fixing the TM as the patch also landed on 3.2.
Target Milestone: Bugzilla 4.0 → Bugzilla 3.2
Patch for Bugzilla 3.0.5. Needed to add line to Bugzilla/WebService/Constants.pm for param_required => 50.

Please review
Dave
Attachment #331185 - Flags: review?(LpSolit)
Apologize that the actual code checked in was different that the last patch that was reviewed. I did fix the error before checking in so the tree was not broken. I am attaching the actual patch used here.

Dave
Attachment #330411 - Attachment is obsolete: true
Attachment #331188 - Flags: review+
Oops, backported the wrong patch to 3.0.5. Changing the review request to mkanat. Feel free to deny this request if you do not feel we need this for 3.0.5.

Dave
Attachment #331185 - Flags: review?(LpSolit) → review?(mkanat)
Attachment #331185 - Flags: review?(mkanat) → review+
Flags: approval3.0+
Target Milestone: Bugzilla 3.2 → Bugzilla 3.0
3.0.5:
Checking in Bugzilla/WebService/Constants.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/WebService/Constants.pm,v  <--  Constants.pm
new revision: 1.6.2.5; previous revision: 1.6.2.4
done
Checking in Bugzilla/WebService/User.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/WebService/User.pm,v  <--  User.pm
new revision: 1.4.2.2; previous revision: 1.4.2.1
done
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: