2016-11-28 17:54:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Users
|
|
|
|
class SessionsController < Devise::SessionsController
|
|
|
|
after_action :store_location, only: [:new]
|
2016-11-25 19:34:09 +00:00
|
|
|
|
2016-11-28 17:54:33 +00:00
|
|
|
protected
|
2016-10-22 08:46:39 +00:00
|
|
|
|
2016-11-28 17:54:33 +00:00
|
|
|
def after_sign_in_path_for(resource)
|
|
|
|
stored = stored_location_for(User)
|
|
|
|
return stored if stored
|
2016-10-22 08:46:39 +00:00
|
|
|
|
2016-11-28 17:54:33 +00:00
|
|
|
if request.referer&.match(sign_in_url) || request.referer&.match(sign_up_url)
|
|
|
|
super
|
|
|
|
else
|
|
|
|
request.referer || root_path
|
|
|
|
end
|
2016-10-22 08:46:39 +00:00
|
|
|
end
|
2016-11-25 19:34:09 +00:00
|
|
|
|
2016-11-28 17:54:33 +00:00
|
|
|
private
|
2016-11-25 19:34:09 +00:00
|
|
|
|
2016-11-28 17:54:33 +00:00
|
|
|
def store_location
|
|
|
|
store_location_for(User, params[:redirect_to]) if params[:redirect_to]
|
2016-11-25 19:34:09 +00:00
|
|
|
end
|
|
|
|
end
|
2016-10-19 04:40:52 +00:00
|
|
|
end
|