修改初始化判断条件

This commit is contained in:
hanhh
2021-10-03 22:01:44 +08:00
parent 14b20873c7
commit 6819487a43
3 changed files with 24 additions and 12 deletions
+7 -4
View File
@@ -5,6 +5,7 @@ import * as fs from 'fs';
import config from '../config';
import UserService from '../services/user';
import { celebrate, Joi } from 'celebrate';
import { getFileContentByName } from '../config/util';
const route = Router();
export default (app: Router) => {
@@ -211,12 +212,14 @@ export default (app: Router) => {
try {
const userService = Container.get(UserService);
const authInfo = await userService.getUserInfo();
const envDbContent = getFileContentByName(config.envDbFile);
let isInitialized = true;
if (
!authInfo ||
(Object.keys(authInfo).length === 2 &&
authInfo.username === 'admin' &&
authInfo.password === 'admin')
Object.keys(authInfo).length === 2 &&
authInfo.username === 'admin' &&
authInfo.password === 'admin' &&
envDbContent.length === 0
) {
isInitialized = false;
}
+7 -5
View File
@@ -5,7 +5,7 @@ import routes from '../api';
import config from '../config';
import jwt from 'express-jwt';
import fs from 'fs';
import { getPlatform, getToken } from '../config/util';
import { getFileContentByName, getPlatform, getToken } from '../config/util';
import Container from 'typedi';
import OpenService from '../services/open';
import rewrite from 'express-urlrewrite';
@@ -90,12 +90,14 @@ export default ({ app }: { app: Application }) => {
}
const userService = Container.get(UserService);
const authInfo = await userService.getUserInfo();
const envDbContent = getFileContentByName(config.envDbFile);
let isInitialized = true;
if (
!authInfo ||
(Object.keys(authInfo).length === 2 &&
authInfo.username === 'admin' &&
authInfo.password === 'admin')
Object.keys(authInfo).length === 2 &&
authInfo.username === 'admin' &&
authInfo.password === 'admin' &&
envDbContent.length === 0
) {
isInitialized = false;
}