Merge branch 'develop' of https://gitlink.org.cn/Trustie/forgeplus into develop

This commit is contained in:
“xxq250” 2022-08-16 14:28:52 +08:00
commit 98ae62d181
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,26 @@
class Traces::BaseController < ApplicationController
helper_method :observed_logged_user?, :observed_user
before_action :check_trace_system
def observed_user
@_observed_user ||= (User.find_by_login(params[:user_id]) || User.find_by_id(params[:user_id]))
end
def observed_logged_user?
observed_user.id == User.current&.id
end
protected
def check_auth
return render_forbidden unless current_user.admin? || observed_logged_user?
end
def check_trace_system
code, data, error = Trace::SystemInfoService.call(current_user.trace_token)
return render_ok({code: 501, data: {operate_time: data['operate_time']}, message: '系统维护中'}) if data['status'] === 0
rescue
# 这里根据需求跳转到404
return render_not_found
end
end

View File

@ -6,6 +6,7 @@ json.status message["status"]
json.content message["content"]
json.notification_url message["notification_url"]
json.source message["source"]
json.created_at message["created_at"]
json.time_ago time_from_now(message["created_at"].to_time)
case message["type"]