Sha256: e3aebf7daad6b5bf20bc8150076e4e8fc4597422aa721e9e9478652fbd3818cc

Contents?: true

Size: 466 Bytes

Versions: 6

Compression:

Stored size: 466 Bytes

Contents

module Nyauth
  class ResetPasswordRequest
    include ActiveModel::Model
    attr_reader :email, :client

    def initialize(service_params = {})
      @email = service_params[:email]
    end

    def save(options = {})
      options.reverse_merge!(as: :user)
      klass = options[:as].to_s.classify.constantize
      @client = klass.find_by!(email: @email)
      @client.request_reset_password
    rescue
      errors.add(:base, :invalid_email)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nyauth-0.7.0 app/services/nyauth/reset_password_request.rb
nyauth-0.6.2 app/services/nyauth/reset_password_request.rb
nyauth-0.6.1 app/services/nyauth/reset_password_request.rb
nyauth-0.6.0 app/services/nyauth/reset_password_request.rb
nyauth-0.5.0 app/services/nyauth/reset_password_request.rb
nyauth-0.4.0 app/services/nyauth/reset_password_request.rb