From 26d986d4a820ca1b92a68d708f05478cafa9b416 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Fri, 24 Sep 2021 22:49:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=8D=E5=8A=A1=E7=AB=AFts?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/index.d.ts | 5 +++++ back/loaders/express.ts | 4 ---- back/services/auth.ts | 2 +- typings.d.ts | 6 ------ 4 files changed, 6 insertions(+), 11 deletions(-) create mode 100644 back/index.d.ts diff --git a/back/index.d.ts b/back/index.d.ts new file mode 100644 index 00000000..8fba99c8 --- /dev/null +++ b/back/index.d.ts @@ -0,0 +1,5 @@ +declare namespace Express { + interface Request { + platform: 'desktop' | 'mobile'; + } +} diff --git a/back/loaders/express.ts b/back/loaders/express.ts index bd34d83c..b04daeb9 100644 --- a/back/loaders/express.ts +++ b/back/loaders/express.ts @@ -80,11 +80,7 @@ export default ({ app }: { app: Application }) => { const data = fs.readFileSync(config.authConfigFile, 'utf8'); if (data) { const { token = '', tokens = {} } = JSON.parse(data); - console.log(tokens); - console.log(req.platform); - console.log(tokens[req.platform]); if (headerToken === token || tokens[req.platform] === headerToken) { - console.log('yes'); return next(); } } diff --git a/back/services/auth.ts b/back/services/auth.ts index 04a910b2..d8805e2c 100644 --- a/back/services/auth.ts +++ b/back/services/auth.ts @@ -6,11 +6,11 @@ import * as fs from 'fs'; import _ from 'lodash'; import jwt from 'jsonwebtoken'; import { authenticator } from '@otplib/preset-default'; -import { exec } from 'child_process'; import DataStore from 'nedb'; import { AuthDataType, AuthInfo, LoginStatus } from '../data/auth'; import { NotificationInfo } from '../data/notify'; import NotificationService from './notify'; +import { Request } from 'express'; @Service() export default class AuthService { diff --git a/typings.d.ts b/typings.d.ts index e1244ee2..06c8a5b8 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -8,9 +8,3 @@ declare module '*.svg' { const url: string; export default url; } - -declare namespace Express { - export interface Request { - platform: 'desktop' | 'mobile'; - } -}