diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index f6d76e728..fb5639739 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -452,6 +452,16 @@ class AccountController < ApplicationController render :layout => 'base_edu_account' end + def apply_trail + apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization").first + if apply_action.blank? + ApplyAction.create(:user_id => User.current.id, :status => 0, :container_type => "TrialAuthorization") + end + respond_to do |format| + format.js + end + end + def user_auth @user = User.current diskfile1 = disk_auth_filename('UserAuthentication', @user.id, 'ID') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e7b475671..27127016a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -62,16 +62,16 @@ class ApplicationController < ActionController::Base # 判断用户是否认证 def check_authentication - return true - # uthentication = AuthenticationsUsers.where(:user_id => User.current.id).first - # user_account = User.current.try(:user_extensions).try(:occupation) - # if uthentication.blank? || user_account.blank? - # redirect_to my_account_path - # return - # elsif User.current.authentications == 0 - # redirect_to authentication_account_path - # return - # end + # return true + if params[:action] == "on_search" || params[:action] == "apply_trail" # 之所以这样处理是为了避开account页面ajax加载 + return true + end + authentication = ApplyAction.where(:user_id => User.current.id).first + user_identity = User.current.try(:user_extensions).try(:identity) + if user_identity.blank? || authentication.blank? + redirect_to my_account_path + return + end end def session_expiration diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index fe71494ad..b07fca70f 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -147,21 +147,35 @@ class MyController < ApplicationController end @user = User.current - # 基本资料不完善 @force为false, 完善 @force为true - @force = false - if params[:tip] - @force = true + # 认证 + ue = @user.user_extensions + @trail_authentication = ApplyAction.where(:user_id => User.current.id).first + @authentication = @user.authentication + if ue.identity.nil? + @require_auth = true else - user = UserExtensions.where(:user_id => User.current.id).first - if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? - @force = true - elsif user.identity == 3 && user.school_id.nil? - @force = true + if @trail_authentication.blank? + @require_trail_auth = true end end - - # 用户认证 - @auth = @user.authentication ? false : true + # @require_auth = true + # + # # 基本资料不完善 @force为false, 完善 @force为true + # @force = false + # # @authentication = @user.authentication + # @trail_authentication = AuthenticationsUsers.where(:user_id => User.current.id).first + # if params[:tip] + # @force = true + # else + # user = UserExtensions.where(:user_id => User.current.id).first + # if user.identity.nil? || user.school_id.nil? || User.current.lastname.nil? + # @force = false + # else + # @force = @trail_authentication.blank? ? false : true + # end + # end + # # 用户认证 + # @auth = @user.authentication ? false : true @s_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').first @d_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').first @@ -217,6 +231,7 @@ class MyController < ApplicationController @se.brief_introduction = params[:brief_introduction] if @user.save && @se.save + reward_grade(@user, @user.id, 'Account', 500) # 修改邮箱的时候同步修改到gitlab # if changed_mail || changed_login diff --git a/app/views/account/apply_trail.js.erb b/app/views/account/apply_trail.js.erb new file mode 100644 index 000000000..eb6213a58 --- /dev/null +++ b/app/views/account/apply_trail.js.erb @@ -0,0 +1 @@ +notice_box("申请成功,我们将在一个工作日内完成审核") \ No newline at end of file diff --git a/app/views/layouts/base_edu_account.html.erb b/app/views/layouts/base_edu_account.html.erb index 7b674dd13..da3c91700 100644 --- a/app/views/layouts/base_edu_account.html.erb +++ b/app/views/layouts/base_edu_account.html.erb @@ -30,11 +30,7 @@