邮箱登入

This commit is contained in:
chenjianxing 2020-06-11 14:27:17 +08:00
parent 30c0612c51
commit 155ff74c57
2 changed files with 18 additions and 3 deletions

View File

@ -68,10 +68,15 @@ public class ShiroDBRealm extends AuthorizingRealm {
UserDTO user = userService.getUserDTO(userId);
String msg;
if (user == null) {
msg = "The user does not exist: " + userId;
logger.warn(msg);
throw new UnknownAccountException(Translator.get("user_not_exist") + userId);
user = userService.getUserDTOByEmail(userId);
if (user == null) {
msg = "The user does not exist: " + userId;
logger.warn(msg);
throw new UnknownAccountException(Translator.get("user_not_exist") + userId);
}
userId = user.getId();
}
// local test
if (StringUtils.equals("local", runMode)) {
SessionUser sessionUser = SessionUser.fromUser(user);

View File

@ -147,6 +147,16 @@ public class UserService {
return userDTO;
}
public UserDTO getUserDTOByEmail(String email) {
UserExample example = new UserExample();
example.createCriteria().andEmailEqualTo(email);
List<User> users = userMapper.selectByExample(example);
if (users == null || users.size() <= 0) {
return null;
}
return getUserDTO(users.get(0).getId());
}
public UserRoleDTO getUserRole(String userId) {
UserRoleDTO userRoleDTO = new UserRoleDTO();
//