Sha256: 493858329fc69a28c8016654fa9e8250ffad731f728d2b9013a86a6ea9154b5a
Contents?: true
Size: 974 Bytes
Versions: 5
Compression:
Stored size: 974 Bytes
Contents
module Ecm module UserArea class UserPasswordResetRequest include ActiveModel::Model extend ActiveModel::Callbacks include ActiveModel::Validations::Callbacks attr_accessor :user, :email, :host def self.call(attributes) new(attributes).save end def self.i18n_scope :activerecord end validates :email, :host, presence: true validates :user, presence: true before_validation :load_user after_validation :delete_error_on_user, if: ->() { errors.get(:email).present? } def save return unless valid? self.user.reset_perishable_token self.user.save Ecm::UserArea::UserMailer.password_reset_email(self.user, host).deliver_later end private def load_user self.user = Ecm::UserArea::User.where(email: self.email).first end def delete_error_on_user errors.delete(:user) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems