Sha256: a8fa8246704b2af61ae1fcf845215728ea8405e9abda623cd7f209645bc19eef

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

module Ecm
  module UserArea
    module PasswordResetRequests
      class BaseController < Ecm::UserArea::Configuration.base_controller.constantize
        include ResourcesController::Resources
        include ResourcesController::ResourceInflections
        include ResourcesController::RestResourceUrls
        include ResourcesController::RestActions
        include Controller::RedirectBackConcern

        if Rails.version < '5'
          skip_before_action :authenticate_user!
        else
          skip_before_action :authenticate_user!, raise: false
        end

        def create
          @resource = resource_class.new(permitted_params)
          @resource.host = request.host
          @resource.save
          respond_with @resource, location: after_create_location
        end

        def edit
          @resource = load_user_by_token
          unless @resource
            flash[:error] = t('.user_not_found')
            redirect_to new_user_session_path
            return
          end
          respond_with @resource
        end


        private

        def load_user_by_token
          User.find_using_perishable_token(params[:token])
        end


        def permitted_params
          params.require(resource_class.name.demodulize.underscore.to_sym).permit(:email)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ecm_user_area2-4.0.2 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb
ecm_user_area2-4.0.1 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb
ecm_user_area2-3.1.2 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb
ecm_user_area2-3.1.1 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb
ecm_user_area2-3.1.0 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb
ecm_user_area2-3.0.3 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb
ecm_user_area2-3.0.2 app/controllers/ecm/user_area/password_reset_requests/base_controller.rb