验证码区分mobile与email

This commit is contained in:
lxy 2024-08-19 11:48:02 +08:00
parent 8ba03c64b5
commit 24ccac2059
4 changed files with 34 additions and 26 deletions

View File

@ -606,7 +606,8 @@ export async function loginByMobile<ED extends EntityDict>(
expired: 1, expired: 1,
}, },
filter: { filter: {
mobile, origin: 'mobile',
content: mobile,
code: captcha, code: captcha,
}, },
sorter: [ sorter: [
@ -1574,7 +1575,8 @@ export async function sendCaptcha<ED extends EntityDict>(
'captcha', 'captcha',
{ {
filter: { filter: {
mobile, origin: 'mobile',
content: mobile,
$$createAt$$: { $$createAt$$: {
$gt: now - 3600 * 1000, $gt: now - 3600 * 1000,
}, },
@ -1600,7 +1602,8 @@ export async function sendCaptcha<ED extends EntityDict>(
$$createAt$$: 1, $$createAt$$: 1,
}, },
filter: { filter: {
mobile, origin: 'mobile',
content: mobile,
$$createAt$$: { $$createAt$$: {
$gt: now - duration * 60 * 1000, $gt: now - duration * 60 * 1000,
}, },
@ -1657,7 +1660,8 @@ export async function sendCaptcha<ED extends EntityDict>(
action: 'create', action: 'create',
data: { data: {
id, id,
mobile, origin: 'mobile',
content: mobile,
code, code,
visitorId, visitorId,
env, env,

View File

@ -326,7 +326,8 @@ export async function updateUserPassword<ED extends EntityDict>(params: { userId
id: 1, id: 1,
}, },
filter: { filter: {
mobile, origin: 'mobile',
content: mobile,
code: captcha, code: captcha,
expired: false, expired: false,
}, },

View File

@ -47,7 +47,8 @@ export async function unbindingWechat<ED extends EntityDict>(
expired: 1, expired: 1,
}, },
filter: { filter: {
mobile, origin: 'mobile',
content: mobile,
code: captcha, code: captcha,
}, },
sorter: [{ sorter: [{

View File

@ -4,7 +4,8 @@ import { ActionDef, Index } from 'oak-domain/lib/types';
import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; import { EntityDesc } from 'oak-domain/lib/types/EntityDesc';
export interface Schema extends EntityShape { export interface Schema extends EntityShape {
mobile: String<11>; origin: 'mobile' | 'email';
content: String<32>;
code: String<4>; code: String<4>;
visitorId: Text; visitorId: Text;
reason?: Text; reason?: Text;
@ -36,7 +37,8 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
zh_CN: { zh_CN: {
name: '验证码', name: '验证码',
attr: { attr: {
mobile: '手机号', origin: '源',
content: '内容',
code: '验证码', code: '验证码',
visitorId: '用户标识', visitorId: '用户标识',
reason: '失败原因', reason: '失败原因',
@ -71,7 +73,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
name: 'index_mobile_code', name: 'index_mobile_code',
attributes: [ attributes: [
{ {
name: 'mobile', name: 'content',
direction: 'ASC', direction: 'ASC',
}, },
{ {