修复类型检查

This commit is contained in:
hanhh
2021-09-29 23:15:09 +08:00
parent ca5afe04f8
commit c0bd51cf03
2 changed files with 4 additions and 5 deletions
+3 -4
View File
@@ -45,11 +45,10 @@ export default ({ app }: { app: Application }) => {
if (req.path.startsWith('/open/')) {
const openService = Container.get(OpenService);
const doc = await openService.findTokenByValue(headerToken);
if (doc && doc.tokens.length > 0) {
if (doc && doc.tokens && doc.tokens.length > 0) {
const currentToken = doc.tokens.find((x) => x.value === headerToken);
const key =
req.path.match(/\/open\/([a-z]+)\/*/) &&
req.path.match(/\/open\/([a-z]+)\/*/)[1];
const keyMatch = req.path.match(/\/open\/([a-z]+)\/*/);
const key = keyMatch && keyMatch[1];
if (
doc.scopes.includes(key as any) &&
currentToken &&