Update local register method
This commit is contained in:
parent
69f2fd2fbb
commit
8f9e12a5e0
|
@ -110,6 +110,7 @@ class AccountsController < ApplicationController
|
|||
# params[:login] 邮箱或者手机号
|
||||
# params[:code] 验证码
|
||||
# code_type 1:注册手机验证码 8:邮箱注册验证码
|
||||
# 本地forge注册入口
|
||||
def register
|
||||
begin
|
||||
# 查询验证码是否正确;type只可能是1或者8
|
||||
|
@ -145,23 +146,20 @@ class AccountsController < ApplicationController
|
|||
# 现在因为是验证码,所以在注册的时候就可以激活
|
||||
@user.activate
|
||||
# 必须要用save操作,密码的保存是在users中
|
||||
if @user.save!
|
||||
# todo user_extension
|
||||
UserExtension.create!(user_id: @user.id)
|
||||
# 注册完成,手机号或邮箱想可以奖励500金币
|
||||
# RewardGradeService.call(
|
||||
# @user,
|
||||
# container_id: @user.id,
|
||||
# container_type: pre == 'p' ? 'Phone' : 'Mail',
|
||||
# score: 500
|
||||
# )
|
||||
# 注册时,记录是否是引流用户
|
||||
ip = request.remote_ip
|
||||
ua = UserAgent.find_by_ip(ip)
|
||||
ua.update_column(:agent_type, UserAgent::USER_REGISTER) if ua
|
||||
successful_authentication(@user)
|
||||
# session[:user_id] = @user.id
|
||||
normal_status("注册成功")
|
||||
|
||||
interactor = Gitea::RegisterInteractor.call({username: login, email: email, password: params[:password]})
|
||||
if interactor.success?
|
||||
gitea_user = interactor.result
|
||||
result = Gitea::User::GenerateTokenService.new(username, params[:password]).call
|
||||
@user.gitea_token = result['sha1']
|
||||
@user.gitea_uid = gitea_user['id']
|
||||
if user.save!
|
||||
UserExtension.create!(user_id: user.id)
|
||||
successful_authentication(@user)
|
||||
normal_status("注册成功")
|
||||
end
|
||||
else
|
||||
tip_exception(-1, interactor.error)
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
|
|
Loading…
Reference in New Issue