Skip to content

Commit

Permalink
fix: 已暂时恢复云函数的调试接口(未做鉴权)
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Jul 28, 2021
1 parent 82b0783 commit 23d359e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/app-server/src/api/function.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Constants } from "../constants"
import { Globals } from "../lib/globals"

const db = Globals.db
Expand All @@ -8,7 +9,7 @@ const db = Globals.db
* @returns
*/
export async function getFunctionByName(func_name: string) {
const r = await db.collection('functions')
const r = await db.collection(Constants.function_collection)
.where({ name: func_name })
.getOne()

Expand All @@ -26,7 +27,7 @@ export async function getFunctionByName(func_name: string) {
*/
export async function getFunctionById(func_id: string) {
// 获取函数
const r = await db.collection('functions')
const r = await db.collection(Constants.function_collection)
.where({ _id: func_id })
.getOne()

Expand Down
15 changes: 7 additions & 8 deletions packages/app-server/src/router/function/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Request, Response, Router } from 'express'
import { checkPermission } from '../../api/permission'
import { FunctionContext, CloudFunction } from 'cloud-function-engine'
import * as multer from 'multer'
import * as path from 'path'
Expand Down Expand Up @@ -53,13 +52,13 @@ async function handleInvokeFunction(req: Request, res: Response) {

const debug = req.query?.debug ?? false

// 调试权限验证
if (debug) {
const code = await checkPermission(req['auth']?.uid, 'function.debug')
if (code) {
return res.status(code).send('permission denied')
}
}
// 调试权限验证: @TODO 暂时先注释掉,需要通过令牌来控制调试权限
// if (debug) {
// const code = await checkPermission(req['auth']?.uid, 'function.debug')
// if (code) {
// return res.status(code).send('permission denied')
// }
// }

const funcData = await getFunctionByName(func_name)
if (!funcData) {
Expand Down

0 comments on commit 23d359e

Please sign in to comment.