添加创建于保存用户的方法

This commit is contained in:
z9hang 2014-12-03 11:16:14 +08:00
parent c139213f52
commit 843811cf99
1 changed files with 32 additions and 0 deletions

View File

@ -177,6 +177,38 @@ class AccountController < ApplicationController
end
end
def create_and_save_user login,password,email
@user = User.new
@user.admin = false
@user.register
@user.login = login
@user.mail = email
unless password.blank?
@user.password = password
end
case Setting.self_registration
when '1'
register_by_email_activation(@user)
when '3'
register_automatically(@user)
else
register_manually_by_administrator(@user)
end
if @user.id != nil
ue = @user.user_extensions ||= UserExtensions.new
#ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => )
#ue.identity = params[:identity].to_i
#ue.technical_title = params[:technical_title]
#ue.gender = params[:gender].to_i
ue.user_id = @user.id
#ue.student_id = params[:no]
#ue.location = params[:province] if params[:province] != nil
#ue.location_city = params[:city] if params[:city] != nil
ue.save
end
@user
end
# Token based account activation
def activate
(redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present?