init project

This commit is contained in:
Jasder
2020-03-09 00:40:16 +08:00
commit 2937b2a94d
6549 changed files with 7215173 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
class Users::BindEmailService < ApplicationService
Error = Class.new(StandardError)
attr_reader :user, :params
def initialize(user, params)
@user = user
@params = params
end
def call
Users::BindEmailForm.new(params).validate!
raise Error, '该邮箱已被其他账号绑定' if User.where.not(id: user.id).exists?(mail: params[:email])
code = VerificationCode.where(email: params[:email], code: params[:code], code_type: 5).last
raise Error, '验证码无效' unless code&.effective?
ActiveRecord::Base.transaction do
if user.mail.blank?
RewardGradeService.call(user, container_id: user.id, container_type: 'Mail', score: 500)
end
user.mail = params[:email]
user.save!
end
end
end