功能1修改
parent
5d31fea0eb
commit
66539b8674
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue