Sha256: c76548a4e8443657cf347bb04097f70fcd12ae333f021e582b917a7f55620b09

Contents?: true

Size: 880 Bytes

Versions: 6

Compression:

Stored size: 880 Bytes

Contents

module Nyauth
  class ResetPasswordRequestsController < Nyauth::BaseController
    allow_everyone
    before_action :set_service
    after_action :send_mail, only: [:create], if: -> { @service.errors.blank? }

    def new
    end

    def create
      @service.save(as: nyauth_client_name)
      respond_with(@service, location: Nyauth.configuration.redirect_path_after_reset_password_request.call(nyauth_client_name) || main_app.root_path)
    end

    private

    def set_service
      @service = Nyauth::ResetPasswordRequest.new(reset_password_request_params)
    end

    def reset_password_request_params
      params.fetch(:reset_password_request, {})
            .permit(:email)
    end

    def send_mail
      Nyauth::RequestMailer.request_reset_password(@service.client)
                           .__send__(Nyauth.configuration.mail_delivery_method)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nyauth-0.7.2 app/controllers/nyauth/reset_password_requests_controller.rb
nyauth-0.7.1 app/controllers/nyauth/reset_password_requests_controller.rb
nyauth-0.7.0 app/controllers/nyauth/reset_password_requests_controller.rb
nyauth-0.6.2 app/controllers/nyauth/reset_password_requests_controller.rb
nyauth-0.6.1 app/controllers/nyauth/reset_password_requests_controller.rb
nyauth-0.6.0 app/controllers/nyauth/reset_password_requests_controller.rb