|
|
|
@ -66,7 +66,7 @@ class AccountController < ApplicationController
|
|
|
|
|
if @user.save
|
|
|
|
|
@token.destroy
|
|
|
|
|
flash[:notice] = l(:notice_account_password_updated)
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
redirect_to signin_url
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -92,7 +92,7 @@ class AccountController < ApplicationController
|
|
|
|
|
Mailer.lost_password(token).deliver
|
|
|
|
|
end
|
|
|
|
|
flash[:notice] = l(:notice_account_lost_email_sent)
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
redirect_to signin_url
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -103,7 +103,7 @@ class AccountController < ApplicationController
|
|
|
|
|
def register
|
|
|
|
|
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
|
|
|
|
|
#
|
|
|
|
|
@cache_identityy = params[:identity]||"" #身份
|
|
|
|
|
#@cache_identityy = params[:identity]||"" #身份
|
|
|
|
|
@cache_no = params[:no]||"" #学号
|
|
|
|
|
@cache_technical_title = params[:technical_title]||"" #教师职称
|
|
|
|
|
@cache_province = params[:province]||"" #省份
|
|
|
|
@ -144,22 +144,7 @@ class AccountController < ApplicationController
|
|
|
|
|
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if(@cache_identityy == "")
|
|
|
|
|
if params[:identity] == "2"
|
|
|
|
|
@user.firstname = firstname_code
|
|
|
|
|
@user.lastname = lastname_code
|
|
|
|
|
end
|
|
|
|
|
flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty')
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if(@cache_city == "")
|
|
|
|
|
if params[:identity] == "2"
|
|
|
|
|
@user.firstname = firstname_code
|
|
|
|
|
@user.lastname = lastname_code
|
|
|
|
|
end
|
|
|
|
|
flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty')
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case Setting.self_registration
|
|
|
|
|
when '1'
|
|
|
|
@ -204,7 +189,7 @@ class AccountController < ApplicationController
|
|
|
|
|
token.destroy
|
|
|
|
|
flash[:notice] = l(:notice_account_activated)
|
|
|
|
|
end
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
redirect_to signin_url
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def valid_ajax
|
|
|
|
@ -234,6 +219,10 @@ class AccountController < ApplicationController
|
|
|
|
|
render :json => req
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def email_valid
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def authenticate_user
|
|
|
|
@ -245,7 +234,7 @@ class AccountController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def password_authentication
|
|
|
|
|
user = User.try_to_login(params[:username], params[:password])
|
|
|
|
|
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
|
|
|
|
|
|
|
|
|
if user.nil?
|
|
|
|
|
invalid_credentials
|
|
|
|
@ -255,7 +244,7 @@ class AccountController < ApplicationController
|
|
|
|
|
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
|
|
|
|
|
else
|
|
|
|
|
# Valid user
|
|
|
|
|
successful_authentication(user)
|
|
|
|
|
successful_authentication(user, last_login_on)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -302,7 +291,7 @@ class AccountController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def successful_authentication(user)
|
|
|
|
|
def successful_authentication(user, last_login_on)
|
|
|
|
|
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
|
|
|
|
|
# Valid user
|
|
|
|
|
self.logged_user = user
|
|
|
|
@ -315,13 +304,18 @@ class AccountController < ApplicationController
|
|
|
|
|
code = /\d*/
|
|
|
|
|
#根据home_url生产正则表达式
|
|
|
|
|
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
|
|
|
|
|
if code=~params[:back_url]
|
|
|
|
|
if code=~params[:back_url] && last_login_on != ''
|
|
|
|
|
redirect_to user_activities_path(user)
|
|
|
|
|
else
|
|
|
|
|
if last_login_on == ''
|
|
|
|
|
redirect_to my_account_url
|
|
|
|
|
else
|
|
|
|
|
#by young
|
|
|
|
|
#redirect_back_or_default my_page_path
|
|
|
|
|
redirect_back_or_default User.current
|
|
|
|
|
#redirect_to my_account_url
|
|
|
|
|
#redirect_to User.current
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -363,7 +357,7 @@ class AccountController < ApplicationController
|
|
|
|
|
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
|
|
|
|
Mailer.register(token).deliver
|
|
|
|
|
flash[:notice] = l(:notice_account_register_done)
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
render action: 'email_valid', locals: {:mail => user.mail}
|
|
|
|
|
else
|
|
|
|
|
yield if block_given?
|
|
|
|
|
end
|
|
|
|
@ -380,7 +374,7 @@ class AccountController < ApplicationController
|
|
|
|
|
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
|
|
|
|
self.logged_user = user
|
|
|
|
|
flash[:notice] = l(:notice_account_activated)
|
|
|
|
|
redirect_to my_account_path
|
|
|
|
|
redirect_to my_account_url
|
|
|
|
|
else
|
|
|
|
|
yield if block_given?
|
|
|
|
|
end
|
|
|
|
@ -402,6 +396,6 @@ class AccountController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def account_pending
|
|
|
|
|
flash[:notice] = l(:notice_account_pending)
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
redirect_to signin_url
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|