|
|
|
@ -101,33 +101,22 @@ class AccountController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# User self-registration
|
|
|
|
|
def register
|
|
|
|
|
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
|
|
|
|
|
#
|
|
|
|
|
#@cache_identityy = params[:identity]||"" #身份
|
|
|
|
|
@cache_no = params[:no]||"" #学号
|
|
|
|
|
@cache_technical_title = params[:technical_title]||"" #教师职称
|
|
|
|
|
@cache_province = params[:province]||"" #省份
|
|
|
|
|
@cache_city = params[:city]||"" #城市
|
|
|
|
|
@cache_enterprise_name = params[:enterprise_name]||"" #企业
|
|
|
|
|
|
|
|
|
|
firstname_code = ""
|
|
|
|
|
lastname_code = ""
|
|
|
|
|
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
|
|
|
|
|
if request.get?
|
|
|
|
|
session[:auth_source_registration] = nil
|
|
|
|
|
@user = User.new(:language => current_language.to_s)
|
|
|
|
|
else
|
|
|
|
|
user_params = params[:user] || {}
|
|
|
|
|
@user = User.new
|
|
|
|
|
@user.safe_attributes = user_params
|
|
|
|
|
if params[:identity] == "2" # 2 企业
|
|
|
|
|
firstname_code = @user.firstname
|
|
|
|
|
lastname_code = @user.lastname
|
|
|
|
|
@user.firstname = params[:enterprise_name]
|
|
|
|
|
@user.lastname = l(:field_enterprise)
|
|
|
|
|
end
|
|
|
|
|
@user.admin = false
|
|
|
|
|
@user.register
|
|
|
|
|
#@user = User.new
|
|
|
|
|
#@user.safe_attributes = user_params
|
|
|
|
|
#if params[:identity] == "2" # 2 企业
|
|
|
|
|
# firstname_code = @user.firstname
|
|
|
|
|
# lastname_code = @user.lastname
|
|
|
|
|
# @user.firstname = params[:enterprise_name]
|
|
|
|
|
# @user.lastname = l(:field_enterprise)
|
|
|
|
|
#end
|
|
|
|
|
#@user.admin = false
|
|
|
|
|
#@user.register
|
|
|
|
|
if session[:auth_source_registration]
|
|
|
|
|
@user.activate
|
|
|
|
|
@user.login = session[:auth_source_registration][:login]
|
|
|
|
@ -139,42 +128,59 @@ class AccountController < ApplicationController
|
|
|
|
|
redirect_to my_account_path
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@user.login = params[:user][:login]
|
|
|
|
|
unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank?
|
|
|
|
|
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
us = UsersService.new
|
|
|
|
|
@user = us.register user_params.merge(:should_confirmation_password => true)
|
|
|
|
|
case Setting.self_registration
|
|
|
|
|
when '1'
|
|
|
|
|
register_by_email_activation(@user)
|
|
|
|
|
#register_by_email_activation(@user)
|
|
|
|
|
unless @user.new_record?
|
|
|
|
|
render action: 'email_valid', locals: {:mail => user.mail}
|
|
|
|
|
end
|
|
|
|
|
when '3'
|
|
|
|
|
register_automatically(@user)
|
|
|
|
|
#register_automatically(@user)
|
|
|
|
|
unless @user.new_record?
|
|
|
|
|
self.logged_user = user
|
|
|
|
|
flash[:notice] = l(:notice_account_activated)
|
|
|
|
|
redirect_to my_account_url
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
register_manually_by_administrator(@user)
|
|
|
|
|
#register_manually_by_administrator(@user)
|
|
|
|
|
unless @user.new_record?
|
|
|
|
|
account_pending
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#added by bai
|
|
|
|
|
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.login = params[:user][:login]
|
|
|
|
|
# unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank?
|
|
|
|
|
# @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# case Setting.self_registration
|
|
|
|
|
# when '1'
|
|
|
|
|
# register_by_email_activation(@user)
|
|
|
|
|
# when '3'
|
|
|
|
|
# register_automatically(@user)
|
|
|
|
|
# else
|
|
|
|
|
# register_manually_by_administrator(@user)
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# #added by bai
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if params[:identity] == "2"
|
|
|
|
|
@user.firstname = firstname_code
|
|
|
|
|
@user.lastname = lastname_code
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Token based account activation
|
|
|
|
|