新增设置注册邮箱前缀最小位数
This commit is contained in:
@@ -17,7 +17,7 @@ const accountService = {
|
||||
|
||||
async add(c, params, userId) {
|
||||
|
||||
const {addEmailVerify , addEmail, manyEmail, addVerifyCount} = await settingService.query(c);
|
||||
const {addEmailVerify , addEmail, manyEmail, addVerifyCount, minEmailPrefix} = await settingService.query(c);
|
||||
|
||||
let { email, token } = params;
|
||||
|
||||
@@ -39,6 +39,9 @@ const accountService = {
|
||||
throw new BizError(t('notExistDomain'));
|
||||
}
|
||||
|
||||
if (emailUtils.getName(email).length < minEmailPrefix) {
|
||||
throw new BizError(t('minEmailPrefix', { msg: minEmailPrefix } ));
|
||||
}
|
||||
|
||||
let accountRow = await this.selectByEmailIncludeDel(c, email);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const loginService = {
|
||||
|
||||
const { email, password, token, code } = params;
|
||||
|
||||
let {regKey, register, registerVerify, regVerifyCount} = await settingService.query(c)
|
||||
let {regKey, register, registerVerify, regVerifyCount, minEmailPrefix} = await settingService.query(c)
|
||||
|
||||
if (oauth) {
|
||||
registerVerify = settingConst.registerVerify.CLOSE;
|
||||
@@ -41,16 +41,20 @@ const loginService = {
|
||||
throw new BizError(t('notEmail'));
|
||||
}
|
||||
|
||||
if (emailUtils.getName(email).length < minEmailPrefix) {
|
||||
throw new BizError(t('minEmailPrefix', { msg: minEmailPrefix } ));
|
||||
}
|
||||
|
||||
if (emailUtils.getName(email).length > 64) {
|
||||
throw new BizError(t('emailLengthLimit'));
|
||||
}
|
||||
|
||||
if (password.length > 30) {
|
||||
throw new BizError(t('pwdLengthLimit'));
|
||||
}
|
||||
|
||||
if (emailUtils.getName(email).length > 30) {
|
||||
throw new BizError(t('emailLengthLimit'));
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
throw new BizError(t('pwdMinLengthLimit'));
|
||||
throw new BizError(t('pwdMinLength'));
|
||||
}
|
||||
|
||||
if (!c.env.domain.includes(emailUtils.getDomain(email))) {
|
||||
|
||||
@@ -206,7 +206,8 @@ const settingService = {
|
||||
loginDomain: settingRow.loginDomain,
|
||||
linuxdoClientId: settingRow.linuxdoClientId,
|
||||
linuxdoCallbackUrl: settingRow.linuxdoCallbackUrl,
|
||||
linuxdoSwitch: settingRow.linuxdoSwitch
|
||||
linuxdoSwitch: settingRow.linuxdoSwitch,
|
||||
minEmailPrefix: settingRow.minEmailPrefix
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ import emailMsgTemplate from '../template/email-msg';
|
||||
import emailTextTemplate from '../template/email-text';
|
||||
import emailHtmlTemplate from '../template/email-html';
|
||||
import verifyUtils from '../utils/verify-utils';
|
||||
import domainUtils from "../utils/domain-uitls";
|
||||
|
||||
const telegramService = {
|
||||
|
||||
@@ -50,7 +51,7 @@ const telegramService = {
|
||||
|
||||
const jwtToken = await jwtUtils.generateToken(c, { emailId: email.emailId })
|
||||
|
||||
const webAppUrl = verifyUtils.isDomain(customDomain) ? `https://${customDomain}/api/telegram/getEmail/${jwtToken}` : 'https://www.cloudflare.com/404'
|
||||
const webAppUrl = customDomain ? `${domainUtils.toOssDomain(customDomain)}/api/telegram/getEmail/${jwtToken}` : 'https://www.cloudflare.com/404'
|
||||
|
||||
await Promise.all(tgChatIds.map(async chatId => {
|
||||
try {
|
||||
|
||||
@@ -53,7 +53,7 @@ const userService = {
|
||||
const { password } = params;
|
||||
|
||||
if (password < 6) {
|
||||
throw new BizError(t('pwdMinLengthLimit'));
|
||||
throw new BizError(t('pwdMinLength'));
|
||||
}
|
||||
const { salt, hash } = await cryptoUtils.hashPassword(password);
|
||||
await orm(c).update(user).set({ password: hash, salt: salt }).where(eq(user.userId, userId)).run();
|
||||
@@ -304,7 +304,7 @@ const userService = {
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
throw new BizError(t('pwdMinLengthLimit'));
|
||||
throw new BizError(t('pwdMinLength'));
|
||||
}
|
||||
|
||||
const accountRow = await accountService.selectByEmailIncludeDel(c, email);
|
||||
|
||||
Reference in New Issue
Block a user