Closed Bug 1010623 Opened 10 years ago Closed 10 years ago

Expose /account/status API via FxAccounts.jsm and FxAccountsClient.jsm

Categories

(Firefox :: Firefox Accounts, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 32

People

(Reporter: spenrose, Assigned: spenrose)

References

Details

Attachments

(1 file, 1 obsolete file)

When the FxA server returns ERRNO_INVALID_AUTH_TOKEN, we may want to distinguish (as in bug 1004319) between the case where the account has been deleted and the case where the account exists but the token is invalid for some other reason (such as a password change). The server provides /account/status?uid=<current uid> for this purpose. I propose to expose it more-or-less transparently in these two modules for consumption by FxAcountsManager.jsm and elsewhere.
Attached patch 1010623-account-status.patch (obsolete) — Splinter Review
My goal was a straightforward exposing of the server API for shared code. Thanks Jed!
Attachment #8422855 - Flags: review?(jparsons)
Comment on attachment 8422855 [details] [diff] [review]
1010623-account-status.patch

Review of attachment 8422855 [details] [diff] [review]:
-----------------------------------------------------------------

This is a very useful patch.

As noted in the comments in the test, I think you just need to nest the second promise inside the resolution of the first.

Just make that tweak.  Otherwise, this looks good to me.  Thanks, Sam!

::: services/fxaccounts/tests/xpcshell/test_accounts.js
@@ +60,5 @@
>  
> +  this.accountStatus = function(uid) {
> +    let deferred = Promise.defer();
> +    deferred.resolve(!!uid && (!this._deletedOnServer));
> +    return deferred.promise;

nice

@@ +522,5 @@
> +      do_check_false(result);
> +    }
> +  );
> +
> +  fxa.setSignedInUser(alice).then(

I think you want to nest this promise inside the onResolve clause of the previous one.  Otherwise they may not resolve in order.
Attachment #8422855 - Flags: review?(jparsons) → review+
https://tbpl.mozilla.org/?tree=Try&rev=f0b6451627bc

Thanks Jed! Nice catch on the promise chaining.
Attachment #8422855 - Attachment is obsolete: true
Keywords: checkin-needed
landed this on m-i as https://hg.mozilla.org/integration/mozilla-inbound/rev/75b0548333ca - btw Sam seems your commit message had the wrong bugnumber in it and was metioning bug 1004319 as bug number for the patch. Corrected this now manually :)
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/75b0548333ca
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
We may need to tweak the /account/status endpoint a bit, but the changes should be minor.
(In reply to Chris Karlof [:ckarlof] from comment #6)
> We may need to tweak the /account/status endpoint a bit, but the changes
> should be minor.

Angels-on-the-head-of-a-pin territory: /account/status is an implicitly general API that currently returns only {exists: <boolean>} but appears designed for adding attributes. I implemented accountStatus() to just return the boolean. Now that I've landed that, I kind of think accountStatus() should return the blob. If anyone has string opinions LMK, otherwise I may (or may not) update it.
Proposed changes to /account/status here: https://github.com/mozilla/fxa-auth-server/issues/721

It should be backwards compatible with what was implemented here, but this implementation should be updated to support the new functionality: Bug 1011773.
Product: Core → Firefox
Target Milestone: mozilla32 → Firefox 32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: