Sha256: 4af0b539b75054be45434f686955abc8b6fc6b29ae0497eee98c5f36844174eb

Contents?: true

Size: 918 Bytes

Versions: 6

Compression:

Stored size: 918 Bytes

Contents

module Nyauth
  class ConfirmationRequestsController < Nyauth::BaseController
    allow_everyone
    self.responder = Nyauth::AppResponder

    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_create_request_confirmation.call(nyauth_client_name) || main_app.root_path)
    end

    private

    def set_service
      @service = Nyauth::ConfirmationRequest.new(confirmation_request_params)
    end

    def confirmation_request_params
      params.fetch(:confirmation_request, {})
            .permit(:email)
    end

    def send_mail
      Nyauth::RequestMailer.request_confirmation(@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/confirmation_requests_controller.rb
nyauth-0.7.1 app/controllers/nyauth/confirmation_requests_controller.rb
nyauth-0.7.0 app/controllers/nyauth/confirmation_requests_controller.rb
nyauth-0.6.2 app/controllers/nyauth/confirmation_requests_controller.rb
nyauth-0.6.1 app/controllers/nyauth/confirmation_requests_controller.rb
nyauth-0.6.0 app/controllers/nyauth/confirmation_requests_controller.rb