socialforge/app/services/users_service.rb

40 lines
1.1 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class UsersService
include AccountHelper
#将用户注册的功能函数写这里
#参数约定
#成功返回注册后的User实例失败直接抛异常
def register(params)
@user = User.new
@user.admin = false
@user.register
@user.login = params[:login]
@user.mail = params[:mail]
password = params[:password]
password_confirmation = params[:password_confirmation]
should_confirmation_password = params[:should_confirmation_password]
if !password.blank? && !password_confirmation && should_confirmation_password
@user.password,@user.password_confirmation = password,password_confirmation
elsif !password.blank? && !should_confirmation_password
@user.password = password
else
@user.password = ""
end
case Setting.self_registration
when '1'
@user = email_activation_register(@user)
when '3'
@user = automatically_register(@user)
else
@user = administrator_manually__register(@user)
end
if @user.id != nil
ue = @user.user_extensions ||= UserExtensions.new
ue.user_id = @user.id
ue.save
end
@user
end
end