测试:增加一个测试用接口;修改 config.json 中的默认环境
This commit is contained in:
@@ -263,4 +263,23 @@ export class EntryHandler {
|
||||
const token = await UserModel.findTokenByTel(tel);
|
||||
return resResult(STATUS.SUCCESS, { token });
|
||||
}
|
||||
|
||||
/**
|
||||
* ! 仅用于测试
|
||||
* @description 测试接口,用于查询和返回 token
|
||||
* @param {{ seqId: string, magicWord: string }} msg 要查询的手机号;需要验证的密码
|
||||
* @param {FrontendSession} session
|
||||
* @returns
|
||||
* @memberof EntryHandler
|
||||
*/
|
||||
async debugQueryTokenById(msg: { uid: number, magicWord: string }, session: FrontendSession) {
|
||||
const { uid, magicWord } = msg;
|
||||
console.log('debugQueryTokenById msg:', msg);
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
const user = await UserModel.findTokenByUid(uid);
|
||||
console.log('debugQueryTokenById got user:', user);
|
||||
return resResult(STATUS.SUCCESS, { user });
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
{"env":"dev"}
|
||||
{"env":"development"}
|
||||
|
||||
@@ -182,8 +182,13 @@ export default class User extends BaseModel {
|
||||
|
||||
public static async findTokenByTel(tel: string) {
|
||||
|
||||
const { token } = await UserModel.findOne({ tel }).select('token').lean({ getters: true });
|
||||
return token;
|
||||
const user: UserType = await UserModel.findOne({ tel }).lean();
|
||||
return user.token;
|
||||
}
|
||||
|
||||
public static async findTokenByUid(uid: number) {
|
||||
const user: UserType = await UserModel.findOne({ uid }).lean();
|
||||
return user ? user.token : null;
|
||||
}
|
||||
|
||||
public static async findUserByTel(tel: string) {
|
||||
|
||||
Reference in New Issue
Block a user