2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2017-01-24 00:30:13 +00:00
|
|
|
module Users
|
|
|
|
class RegistrationsController < Devise::RegistrationsController
|
|
|
|
before_action :configure_sign_up_params, only: [:create]
|
|
|
|
before_action :configure_account_update_params, only: [:update]
|
|
|
|
after_action :store_location, only: [:new]
|
2015-11-03 12:56:50 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
protected
|
2014-10-07 21:46:09 +00:00
|
|
|
|
2017-10-16 22:40:48 +00:00
|
|
|
def after_inactive_sign_up_path_for(resource)
|
|
|
|
sign_in_path
|
|
|
|
end
|
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
def after_update_path_for(resource)
|
|
|
|
signed_in_root_path(resource)
|
|
|
|
end
|
2015-11-03 12:56:50 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
def after_sign_in_path_for(resource)
|
|
|
|
stored = stored_location_for(User)
|
|
|
|
return stored if stored
|
2016-10-19 04:40:52 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
if request.referer&.match(sign_in_url) || request.referer&.match(sign_up_url)
|
|
|
|
super
|
|
|
|
else
|
|
|
|
request.referer || root_path
|
|
|
|
end
|
2016-10-19 04:40:52 +00:00
|
|
|
end
|
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
private
|
2015-11-03 12:56:50 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
def store_location
|
|
|
|
store_location_for(User, params[:redirect_to]) if params[:redirect_to]
|
|
|
|
end
|
2016-10-17 00:22:00 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
def configure_sign_up_params
|
|
|
|
devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :joinedwithcode])
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
def configure_account_update_params
|
|
|
|
devise_parameter_sanitizer.permit(:account_update, keys: [:image])
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
end
|
2014-10-07 21:46:09 +00:00
|
|
|
end
|