|
|
@ -34,10 +34,11 @@ class ApplicationController < ActionController::Base
|
|
|
|
User.current.admin? || User.current.business?
|
|
|
|
User.current.admin? || User.current.business?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 访问课堂时没权限直接弹加入课堂的弹框 :409
|
|
|
|
def user_course_identity
|
|
|
|
def user_course_identity
|
|
|
|
@user_course_identity = current_user.course_identity(@course)
|
|
|
|
@user_course_identity = current_user.course_identity(@course)
|
|
|
|
if @user_course_identity > Course::STUDENT && @course.is_public == 0
|
|
|
|
if @user_course_identity > Course::STUDENT && @course.is_public == 0
|
|
|
|
tip_exception(403, "您没有权限进入")
|
|
|
|
tip_exception(409, "您没有权限进入")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
uid_logger("###############user_course_identity:#{@user_course_identity}")
|
|
|
|
uid_logger("###############user_course_identity:#{@user_course_identity}")
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -186,15 +187,32 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
|
|
|
|
|
|
|
# 系统全局认证
|
|
|
|
# 系统全局认证
|
|
|
|
def check_auth
|
|
|
|
def check_auth
|
|
|
|
if current_user.certification != 1 && current_user.apply_actions.exists?(container_type: 'TrialAuthorization', status: 0)
|
|
|
|
|
|
|
|
tip_exception(408, "您的试用申请正在审核中,请耐心等待")
|
|
|
|
|
|
|
|
elsif current_user.certification != 1
|
|
|
|
|
|
|
|
day_cer = UserDayCertification.find_by(user_id: current_user.id)
|
|
|
|
day_cer = UserDayCertification.find_by(user_id: current_user.id)
|
|
|
|
tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
|
|
|
|
# 如果注册超过24小时则需要完善资料及授权
|
|
|
|
elsif !current_user.profile_completed?
|
|
|
|
if (Time.now.to_i - day_cer.try(:created_at).to_i) > 86400
|
|
|
|
|
|
|
|
if !current_user.profile_completed?
|
|
|
|
info_url = '/account/profile'
|
|
|
|
info_url = '/account/profile'
|
|
|
|
tip_exception(402, info_url)
|
|
|
|
tip_exception(402, info_url)
|
|
|
|
|
|
|
|
elsif current_user.certification != 1
|
|
|
|
|
|
|
|
if current_user.apply_actions.exists?(container_type: 'TrialAuthorization', status: 0)
|
|
|
|
|
|
|
|
tip_exception(408, "您的试用申请正在审核中,请耐心等待")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tip_exception(407, "系统未授权")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if current_user.certification != 1 && current_user.apply_actions.exists?(container_type: 'TrialAuthorization', status: 0)
|
|
|
|
|
|
|
|
# tip_exception(408, "您的试用申请正在审核中,请耐心等待")
|
|
|
|
|
|
|
|
# elsif (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
|
|
|
|
|
|
|
|
# if !current_user.profile_completed?
|
|
|
|
|
|
|
|
# info_url = '/account/profile'
|
|
|
|
|
|
|
|
# tip_exception(402, info_url)
|
|
|
|
|
|
|
|
# elsif current_user.certification != 1
|
|
|
|
|
|
|
|
# day_cer = UserDayCertification.find_by(user_id: current_user.id)
|
|
|
|
|
|
|
|
# tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def start_user_session(user)
|
|
|
|
def start_user_session(user)
|
|
|
|