Sha256: cc95fce5be85c4d4e041482faa912974a64ae9cb60bf272ed1d0f3292b1c90c4

Contents?: true

Size: 851 Bytes

Versions: 29

Compression:

Stored size: 851 Bytes

Contents

module RailsBase::Authentication
	class SendForgotPassword < RailsBase::ServiceBase
		delegate :email, to: :context

		def call
			user = User.find_for_authentication(email: email)

			if user.nil?
				log(level: :warn, msg: "Failed to find email assocaited to #{email}. Not sending email")
				context.fail!(message: "Failed to send forget password to #{email}", redirect_url: '')
			end
			email_send = SendVerificationEmail.call(user: user, reason: Constants::VFP_REASON)

			if email_send.failure?
				log(level: :error, msg: "Failed to send forget password: #{email_send.message}")
				context.fail!(message: email_send.message, redirect_url: '/')
			end

			context.message = 'You should receive an email shortly.'
		end

		def validate!
			raise "Expected email to be a String. Received #{email.class}" unless email.is_a? String
		end
	end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
rails_base-0.75.6 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.75.5 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.75.4 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.75.3 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.75.2 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.75.1 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.75.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.74.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.73.1 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.73.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.72.1 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.72.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.71.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.70.1.pre app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.70.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.61.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.60.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.58.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.57.0 app/services/rails_base/authentication/send_forgot_password.rb
rails_base-0.56.0 app/services/rails_base/authentication/send_forgot_password.rb