|
@@ -17,26 +17,11 @@ class LoginService extends CrudService {
|
|
async login(data) {
|
|
async login(data) {
|
|
const { mobile, password } = data;
|
|
const { mobile, password } = data;
|
|
|
|
|
|
- let user = await this.model.findOne({ mobile });
|
|
+ const user = await this.model.findOne({ mobile }, '+password');
|
|
- const flag = true;
|
|
|
|
- if (!user) {
|
|
|
|
- user = await this.model.findOne({ mobile });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (!user) {
|
|
if (!user) {
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
}
|
|
}
|
|
- let _user = '';
|
|
+ if (user.password.secret !== password) {
|
|
-
|
|
|
|
-
|
|
|
|
- if (flag) {
|
|
|
|
-
|
|
|
|
- _user = await this.model.findOne({ mobile, password });
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- _user = await this.model.findOne({ mobile, password });
|
|
|
|
- }
|
|
|
|
- if (_user === '') {
|
|
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
}
|
|
}
|
|
|
|
|