Sha256: cd6853be615c83298f4548418e19dad6752358b58943061ffc857ce2c74d318f

Contents?: true

Size: 1.35 KB

Versions: 57

Compression:

Stored size: 1.35 KB

Contents

module Cmor
  module UserArea
    module PasswordResetRequests
      class BaseController < Cmor::UserArea::Configuration.base_controller.constantize
        include Rao::ResourcesController::ResourcesConcern
        include Rao::ResourcesController::ResourceInflectionsConcern
        include Rao::ResourcesController::RestResourceUrlsConcern
        include Rao::ResourcesController::RestActionsConcern
        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

57 entries across 57 versions & 1 rubygems

Version Path
cmor_user_area-0.0.60.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.59.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.58.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.57.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.56.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.55.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.54.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.53.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.52.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.51.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.50.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.49.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.48.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.45.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.44.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.43.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.42.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.41.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.40.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb
cmor_user_area-0.0.39.pre app/controllers/cmor/user_area/password_reset_requests/base_controller.rb