zooniverse / scribeAPI

scribe API
MIT License
79 stars 25 forks source link

fetch user on tutorial complete #579

Open gr- opened 8 years ago

gr- commented 8 years ago

I noticed a misbehavior when introductory tutorial is completed : the login material just disappears. Actually, I was expecting it takes into account the new guest user (if not previously logged in) and propose to log in with the many options (Facebook, google, etc.) depending on the project settings.

As far as I understand, the Coffeescript @state cannot capture the new registered guest user after the line request = $.post "/tutorial_complete" in function setTutorialComplete from apps.cjx. I guess a sort of @fetchUser to refresh the state should be ok, but it doesn't work. It may be the processor is away after the post request since users_controller#tutorial_complete asks for rendering a new page ?! Help is welcome to fix this minor issue.

gr- commented 8 years ago

I answer to myself!

If I replace in app/assets/javascripts/components/app.cjsx this line

@setState user: $.extend(@state.user ? {}, tutorial_complete: true)

by those lines

@setState user: $.extend(@state.user ? {}, tutorial_complete: true) if @state.user?
@setState user: $.extend(@state.user ? {}, tutorial_complete: true, guest: true) if not @state.user?

then the login material behaves the right way (thanks to the guest flag). Note that you have to match the user state (guest: true statement) with the render conditions in the login.cjsx script.

Not totally sure about all the side effects...