优化认证

This commit is contained in:
sijinhui
2024-04-01 22:30:35 +08:00
parent 070f143541
commit f5874a4d3d
3 changed files with 14 additions and 21 deletions

View File

@@ -1,6 +1,8 @@
import * as pinyin from "tiny-pinyin";
export const DENY_LIST: string[] = [
"suibian", "某某", "张三", "李四", "啊实打实", "官方回复电话", "笑死", "观化听风", "null", "undefined",
"zhangsan",
]
export const ADMIN_LIST: string[] = [
"司金辉", "sijinhui", "sijinhui@qq.com",
@@ -91,8 +93,12 @@ export function isName(input: string): boolean {
if (!input || input === "") {
return false;
}
if (DENY_LIST.includes(input)) {
return false;
try {
if (DENY_LIST.includes(input.toLowerCase()) || pinyin.convertToPinyin(input).toLowerCase()) {
return false;
}
} catch (e) {
console.log('[isName]', e)
}
return isEmail(input) || (input.length >= 2 && isHanZi(input)) || (isPinYin(input) >= 2);
}