mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 09:34:31 +08:00
修复订阅链接正则判断
This commit is contained in:
+6
-9
@@ -7,6 +7,7 @@ import SystemService from '../services/system';
|
|||||||
import { celebrate, Joi } from 'celebrate';
|
import { celebrate, Joi } from 'celebrate';
|
||||||
import UserService from '../services/user';
|
import UserService from '../services/user';
|
||||||
import { t } from '../shared/i18n';
|
import { t } from '../shared/i18n';
|
||||||
|
import { isDefaultAuthInfo } from '../shared/auth';
|
||||||
import {
|
import {
|
||||||
getUniqPath,
|
getUniqPath,
|
||||||
handleLogPath,
|
handleLogPath,
|
||||||
@@ -39,14 +40,7 @@ export default (app: Router) => {
|
|||||||
const { version, changeLog, changeLogLink, publishTime } =
|
const { version, changeLog, changeLogLink, publishTime } =
|
||||||
await parseVersion(config.versionFile);
|
await parseVersion(config.versionFile);
|
||||||
|
|
||||||
let isInitialized = true;
|
const isInitialized = !isDefaultAuthInfo(authInfo);
|
||||||
if (
|
|
||||||
Object.keys(authInfo).length === 2 &&
|
|
||||||
authInfo.username === 'admin' &&
|
|
||||||
authInfo.password === 'admin'
|
|
||||||
) {
|
|
||||||
isInitialized = false;
|
|
||||||
}
|
|
||||||
res.send({
|
res.send({
|
||||||
code: 200,
|
code: 200,
|
||||||
data: {
|
data: {
|
||||||
@@ -401,7 +395,10 @@ export default (app: Router) => {
|
|||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const userService = Container.get(UserService);
|
const userService = Container.get(UserService);
|
||||||
await userService.resetAuthInfo(req.body);
|
const result = await userService.resetAuthInfo(req.body);
|
||||||
|
if (result) {
|
||||||
|
return res.send(result);
|
||||||
|
}
|
||||||
res.send({ code: 200, message: t('更新成功') });
|
res.send({ code: 200, message: t('更新成功') });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return next(e);
|
return next(e);
|
||||||
|
|||||||
+5
-11
@@ -8,8 +8,9 @@ import { getPlatform, getToken } from '../config/util';
|
|||||||
import rewrite from 'express-urlrewrite';
|
import rewrite from 'express-urlrewrite';
|
||||||
import { errors } from 'celebrate';
|
import { errors } from 'celebrate';
|
||||||
import { serveEnv } from '../config/serverEnv';
|
import { serveEnv } from '../config/serverEnv';
|
||||||
import { IKeyvStore, shareStore } from '../shared/store';
|
import { shareStore } from '../shared/store';
|
||||||
import { isValidToken } from '../shared/auth';
|
import { isValidToken, isDefaultAuthInfo } from '../shared/auth';
|
||||||
|
import { AuthInfo } from '../data/system';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { t } from '../shared/i18n';
|
import { t } from '../shared/i18n';
|
||||||
import { AppScope } from '../data/open';
|
import { AppScope } from '../data/open';
|
||||||
@@ -142,16 +143,9 @@ export default ({ app }: { app: Application }) => {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const authInfo =
|
const authInfo =
|
||||||
(await shareStore.getAuthInfo()) || ({} as IKeyvStore['authInfo']);
|
(await shareStore.getAuthInfo()) || ({} as AuthInfo);
|
||||||
|
|
||||||
let isInitialized = true;
|
let isInitialized = !isDefaultAuthInfo(authInfo);
|
||||||
if (
|
|
||||||
Object.keys(authInfo).length === 2 &&
|
|
||||||
authInfo.username === 'admin' &&
|
|
||||||
authInfo.password === 'admin'
|
|
||||||
) {
|
|
||||||
isInitialized = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isInitialized) {
|
if (isInitialized) {
|
||||||
return res.send({ code: 450, message: t('未知错误') });
|
return res.send({ code: 450, message: t('未知错误') });
|
||||||
|
|||||||
@@ -517,6 +517,9 @@ export default class UserService {
|
|||||||
|
|
||||||
public async resetAuthInfo(info: Partial<AuthInfo>) {
|
public async resetAuthInfo(info: Partial<AuthInfo>) {
|
||||||
const { retries, twoFactorActivated, password, username } = info;
|
const { retries, twoFactorActivated, password, username } = info;
|
||||||
|
if (password === 'admin') {
|
||||||
|
return { code: 400, message: t('密码不能设置为admin') };
|
||||||
|
}
|
||||||
const authInfo = await this.getAuthInfo();
|
const authInfo = await this.getAuthInfo();
|
||||||
const payload = pickBy(
|
const payload = pickBy(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
import { AuthInfo, TokenInfo } from '../data/system';
|
import { AuthInfo, TokenInfo } from '../data/system';
|
||||||
|
|
||||||
|
export function isDefaultAuthInfo(authInfo: AuthInfo): boolean {
|
||||||
|
return (
|
||||||
|
Object.keys(authInfo).length === 2 &&
|
||||||
|
authInfo.username === 'admin' &&
|
||||||
|
authInfo.password === 'admin'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates if a token exists in the authentication info.
|
* Validates if a token exists in the authentication info.
|
||||||
* Supports both legacy string tokens and new TokenInfo array format.
|
* Supports both legacy string tokens and new TokenInfo array format.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import isNil from 'lodash/isNil';
|
|||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
const repoUrlRegx = /([^\/\:]+\/[^\/]+)(?=\.git)/;
|
const repoUrlRegx = /([^\/\:]+\/[^\/]+)(?=\.git)/;
|
||||||
const fileUrlRegx = /([^\/\:]+\/[^\/\.]+)\.[a-z]+$/;
|
const fileUrlRegx = /([^\/\:]+\/[^\/\.]+)\.[a-z]+(\?[^\s]*)?(#.*)?$/;
|
||||||
|
|
||||||
const SubscriptionModal = ({
|
const SubscriptionModal = ({
|
||||||
subscription,
|
subscription,
|
||||||
|
|||||||
Reference in New Issue
Block a user