Closed Bug 1082309 Opened 10 years ago Closed 9 years ago

Cannot use Persona locally without manually editing `site_config.js`

Categories

(Marketplace Graveyard :: Consumer Pages, defect, P4)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: cvan, Unassigned)

References

()

Details

Related to bug 1082195, unfortunately, using Persona in the absence of the waffle switch doesn't seem to be working either.

Because of the errors I saw in bug 1082195, this is how I first tried stubbing out FxA:

> diff --git a/src/media/js/commonplace/capabilities.js b/src/media/js/commonplace/capabilities.js
> index e8c5c0b..9afcd8f 100644
> --- a/src/media/js/commonplace/capabilities.js
> +++ b/src/media/js/commonplace/capabilities.js
> @@ -29,11 +29,13 @@ define('capabilities', ['settings'], function(settings) {
>      // Note: persona will be true for nativeFxA, since it uses the same JavaScript API.
>      // FallbackFxA uses a completely different path, though.
>      static_caps.persona = function() {
> +        return true;
>          return ((!!navigator.id || !!navigator.mozId) &&
>                  !static_caps.phantom &&
>                  !static_caps.fallbackFxA());
>      };
>      static_caps.nativeFxA = function() {
> +        return false;
>          return (static_caps.firefoxOS &&
>                  settings.switches.indexOf('firefox-accounts') !== -1 &&
>                  window.location.protocol === 'app:' &&
> @@ -41,6 +43,7 @@ define('capabilities', ['settings'], function(settings) {
>  
>      };
>      static_caps.fallbackFxA = function() {
> +        return false;
>          return (!static_caps.nativeFxA() &&
>                  settings.switches.indexOf('firefox-accounts') !== -1);
>      };
> 

And that didn't work. I had to manually stub out some code in `site_config.js`:

> diff --git a/src/media/js/commonplace/site_config.js b/src/media/js/commonplace/site_config.js
> index 70c9dde..a65fbb7 100644
> --- a/src/media/js/commonplace/site_config.js
> +++ b/src/media/js/commonplace/site_config.js
> @@ -8,9 +8,9 @@ define('site_config', ['defer', 'requests', 'settings', 'urls'],
>      function fetch() {
>          var def = defer.Deferred();
>          requests.get(urls.api.url('site-config')).done(function(data) {
> -            settings.fxa_auth_url = data.fxa.fxa_auth_url;
> -            settings.fxa_auth_state = data.fxa.fxa_auth_state;
> -            settings.switches = data.waffle.switches || [];
> +            settings.fxa_auth_url = '';
> +            settings.fxa_auth_state = '';
> +            settings.switches = [];
>              def.resolve(data);
>          }).always(function() {
>              def.resolve();
> 

And sometimes, whenever I opened my local Marketplace (in Chrome and Firefox), the "Sign In" button wasn't appearing and the throbber kept spinning forever (even though Persona's `include.js` was on the page):

    https://cloud.githubusercontent.com/assets/203725/4623385/3cf68dfe-534d-11e4-8c3e-021bb1fa0e2a.png

And then when the Persona pop-up window did appear upon clicking "Sign In," I kept hitting a bunch of "No profile found" errors.

    https://www.dropbox.com/s/y4ndvt4vudxc17q/Screenshot%202014-10-13%2019.49.32.png?dl=0

Somehow, I was able to finally log in to Persona.

––

Feel free to file separate bugs, but here are the issues I don't have answers to:

1. As a developer/contributor, how am I supposed to toggle between FxA and Persona? What's the intended flow? That flow should be documented and ideally not *require* Docker.
2. Is there some type of race condition or weird behaviour causing the "Sign In" button to not appear (a throbber appears forever)? (Was reproducible in both Firefox and Chrome.)
3. Why was I encountering "No profile found" messages for my email (which is valid and has always worked previously)? (Was reproducible in both Firefox and Chrome.)
4. Why was I able to finally log in without issues? What made the issues disappear?
FWIW, logging into Stage seemed to work. But people should investigate this more, as I'm sure we've got more devs pointing their Fireplaces at -dev than at stage.
The only thing that should be necessary is something like this :
 diff --git a/src/media/js/commonplace/site_config.js b/src/media/js/commonplace/site_config.js
 index efe272a..03c221a 100644
 --- a/src/media/js/commonplace/site_config.js
 +++ b/src/media/js/commonplace/site_config.js
 @@ -12,7 +12,7 @@ define('site_config', ['defer', 'requests', 'settings', 'urls'],
                  settings.fxa_auth_url = data.fxa.fxa_auth_url;
                  settings.fxa_auth_state = data.fxa.fxa_auth_state;
              }
 -            settings.switches = data.waffle.switches || [];
 +            settings.switches = [];  // data.waffle.switches || [];
              def.resolve(data);
          }).always(function() {
              def.resolve();


Since the switch is enabled on -dev. Although, with this, I'm getting the same "No profile found" error as you are. It works fine with a local zamboni install, so I'm not sure what's going on.
See Also: → 1082195
Priority: -- → P4
I assume this doesn't matter, now that we're ditching Persona?
Now using FxA and it works locally.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
This was fixed in another bug by Allen.
Resolution: INVALID → FIXED
You need to log in before you can comment on or make changes to this bug.