Skip to content

Commit

Permalink
fix(log-server): miss log for request_id required (#1421)
Browse files Browse the repository at this point in the history
  • Loading branch information
0fatal committed Jul 25, 2023
1 parent 2f49a06 commit ea07b91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions services/log-server/src/handler/add-function-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import verifyAppid from '../helper/verify-appid'
const addFunctionLog: RequestHandler = async (req, res) => {
const { appid, log } = req.body
const token = req.headers['x-token'] as string

if (!appid) {
return res.status(400).send('appid is required')
}

if (!token || !verifyAppid(appid, token)) {
if (!token || !verifyAppid(appid, token)) {
return res.status(403).send('forbidden')
}

if (!log || typeof log !== 'object' || !log.request_id || !log.func) {
if (!log || typeof log !== 'object' || !log.func) {
return res.status(400).send('bad log format')
}

Expand Down
4 changes: 2 additions & 2 deletions services/log-server/src/helper/verify-appid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jwt from 'jsonwebtoken'
import Config from '../config'

const verifyAppid = (appid: string, token: string): boolean => {
const verifyAppid = (appid: string, token: string): boolean => {
try {
const decoded = jwt.verify(token, Config.JWT_SECRET)
return decoded['appid'] === appid
Expand All @@ -10,4 +10,4 @@ const verifyAppid = (appid: string, token: string): boolean => {
}
}

export default verifyAppid
export default verifyAppid

0 comments on commit ea07b91

Please sign in to comment.