Loomio

'sign in to participate' button

MI mix irving Public Seen 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

MI

mix irving Tue 1 Jan 2013 12:14AM

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

JL

Jon Lemmon Fri 4 Jan 2013 11:15AM

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
MI

mix irving Mon 7 Jan 2013 1:02AM

made, awaiting merge :P

MI

mix irving Tue 5 Feb 2013 2:25AM

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

JL

Jon Lemmon Wed 6 Feb 2013 9:50AM

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. =)

MI

mix irving Thu 7 Feb 2013 5:04AM

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