功能1修改

dv-1
王熙朝 2024-04-13 14:49:30 +08:00
parent 5d31fea0eb
commit 66539b8674
3 changed files with 20 additions and 5 deletions

View File

@ -34,7 +34,7 @@ public class TokenController {
@PostMapping("login") @PostMapping("login")
public Result<?> login (@RequestBody LoginBody form) { public Result<?> login (@RequestBody LoginBody form) {
// 用户登录 // 用户登录
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword()); LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getEmail(), form.getPassword());
// 获取登录token // 获取登录token
return Result.success(tokenService.createToken(userInfo)); return Result.success(tokenService.createToken(userInfo));
} }

View File

@ -11,6 +11,11 @@ public class LoginBody {
*/ */
private String username; private String username;
/**
*
*/
private String email;
/** /**
* *
*/ */
@ -24,6 +29,14 @@ public class LoginBody {
this.username = username; this.username = username;
} }
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword () { public String getPassword () {
return password; return password;
} }
@ -31,4 +44,6 @@ public class LoginBody {
public void setPassword (String password) { public void setPassword (String password) {
this.password = password; this.password = password;
} }
} }

View File

@ -40,11 +40,11 @@ public class SysLoginService {
/** /**
* *
*/ */
public LoginUser login (String username, String password) { public LoginUser login (String username, String email, String password) {
// 用户名或密码为空 错误 // 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username, password)) { if (StringUtils.isAnyBlank(username, email, password)) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/邮箱/密码必须填写");
throw new ServiceException("用户/密码必须填写"); throw new ServiceException("用户/邮箱/密码必须填写");
} }
// 密码如果不在指定范围内 错误 // 密码如果不在指定范围内 错误
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH if (password.length() < UserConstants.PASSWORD_MIN_LENGTH