add Authorization Bearer token

This commit is contained in:
xxq250 2026-06-30 10:24:28 +08:00
parent 480bd8985a
commit 1efee8d1c4
1 changed files with 7 additions and 2 deletions

View File

@ -313,8 +313,13 @@ class ApplicationController < ActionController::Base
header = request.authorization
pattern = /^Bearer /i
token = header.gsub(pattern, "")
User.current, message = Bot.decode_jwt_token(token)
tip_exception(401, message) if message.present?
user = User.find_by(gitea_token: token)
if user.present?
User.current = user
else
User.current, message = Bot.decode_jwt_token(token)
tip_exception(401, message) if message.present?
end
else
if @doorkeeper_token.present?
# client方法对接需要一直带着用户标识uid