|
@@ -17,14 +17,14 @@ class LoginService extends CrudService {
|
|
|
|
|
|
// 用户登录
|
|
|
async login(data) {
|
|
|
- const { mobile, passwd } = data;
|
|
|
+ const { phone, passwd } = data;
|
|
|
// 根据用户输入的手机号查询其他用户表中是否存在相应数据
|
|
|
- const user = await this.model.findOne({ mobile });
|
|
|
+ const user = await this.model.findOne({ phone });
|
|
|
// 如果用户不存在抛出异常
|
|
|
if (!user) {
|
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
|
}
|
|
|
- const _user = await this.model.findOne({ mobile }, '+passwd');
|
|
|
+ const _user = await this.model.findOne({ phone }, '+passwd');
|
|
|
// 将用户输入的密码进行加密并与查询到的用户数据密码相比对
|
|
|
const pas = await this.createJwtPwd(passwd);
|
|
|
// 如果两个密码不一致抛出异常
|
|
@@ -55,10 +55,10 @@ class LoginService extends CrudService {
|
|
|
}
|
|
|
|
|
|
// 创建登录Token
|
|
|
- async createJwt({ id, name, mobile, roles, remark, openid }) {
|
|
|
+ async createJwt({ id, name, phone, roles, remark, openid }) {
|
|
|
const { secret, expiresIn = '1d', issuer = type } = this.config.jwt;
|
|
|
- const subject = mobile;
|
|
|
- const res = { uid: id, name, mobile, roles, openid, remark };
|
|
|
+ const subject = phone;
|
|
|
+ const res = { uid: id, name, phone, roles, openid, remark };
|
|
|
const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
|
|
|
return token;
|
|
|
}
|