Skip to content
This repository

Observer API's onlogin leads to an expensive backend call on each page load? #2145

Closed
fmarier opened this Issue July 23, 2012 · 4 comments

2 participants

Francois Marier Dan Callahan
Francois Marier
Collaborator

Hopefully this is just me not using the Observer API properly, but if you look at the onlogin code in Libravatar, you will see that any onlogin call with a valid assertion will cause this:

  1. the JS front-end does a POST to the backend
  2. the backend then receives this request and does a POST to the Persona verifier
  3. the front-end then does nothing unless the logged in user has changed

Now, I can see a way to eliminate all of this: the JS front-end could parse the assertion and extract the email out of it. However, I'm not sure we want to recommend that people do that.

Is there a better way to handle this?

Dan Callahan
Owner

How does passing loggedInEmail impact this? That should avoid the onlogin call altogether, right? Is there a reason you'd rather not use loggedInEmail?

Francois Marier
Collaborator

@callahad I'm using loggedInUser maybe that's the problem.

So if I use loggedInEmail then neither onlogin nor onlogout will fire when the right user is logged in?

Dan Callahan
Owner

@fmarier Correct! Unfortunately, loggedInUser got delayed and hasn't entered production yet. Even worse, I can't update MDN to note the slip. It will go live with our next production push.

Francois Marier
Collaborator

As usual, @callahad was right :)

Replacing loggedInUser with loggedInEmail does prevent the unnecessary onlogin calls.

I'll close this bug, but we should make a mental note (if there isn't one already) to make sure that this is well documented.

Francois Marier fmarier closed this July 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.