Loomio

'sign in to participate' button

mix irving PublicSeen by 38

ideally this should generate some sort of :return_to variable so the user is returned to the page they wanted to participate in after sign in

mix irving

Need to do some reading on how Devise is being used and how Loomio is signing in users.

looked at implementing something like this https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in
(don't understand all of this, couldn't get it working despite trying the code in all the seemingly relevant controllers).

could do something like top solution here
http://stackoverflow.com/questions/6989421/after-a-successful-devise-login-how-to-redirect-user-back-to-previous-action-th
but not sure this fits with how loomio is operating

Jon Lemmon

Yep, that stackoverflow solution looks pretty good. And instead of creating a redirect_back_or_to method I think you can just override the after_sign_in_path_for(resource) method as mentioned here. Something like:

class ApplicationController < ActionController::Base
  after_filter :store_location

  def after_sign_in_path_for(resource)
    redirect_to(session[:return_to] || alternate)
    clear_stored_location
  end

  private
  def store_location
    session[:return_to] = request.fullpath
  end

  def clear_stored_location
    session[:return_to] = nil
  end
end

mix irving

made, awaiting merge :P

mix irving

merged on jan 6.
I thought this was live, though maybe i was dreaming... not working on main site atm.

Jon Lemmon

Nope. Not live yet. We've got quite a back-catalog of features that haven't quite gotten deployed yet unfortunately. This is mainly to do with the fact that it's been a busy holiday and we still haven't streamlined our QA process yet. Expect to see the changes sometime next week. =)

mix irving

yeah cool.
just a case of finding myself in the position of that feature being useful then being like "hey, I'm sure i fixded that" :P