use of mingzuozhibi.security.UserDetailsImpl in project mzzb-server by mingzuozhibi.
the class SessionController method sessionLogin.
@PostMapping(value = "/api/session", produces = MEDIA_TYPE)
public String sessionLogin(@JsonArg("$.username") String username, @JsonArg("$.password") String password) {
User user = dao.lookup(User.class, "username", username);
if (user == null) {
if (LOGGER.isInfoEnabled()) {
infoRequest("[用户名称不存在: username={}]", username);
}
return errorMessage("用户名称不存在");
}
UserDetails userDetails = new UserDetailsImpl(user);
if (!userDetails.getPassword().equals(password)) {
if (LOGGER.isInfoEnabled()) {
infoRequest("[用户密码错误: username={}]", username);
}
return errorMessage("用户密码错误");
}
if (!userDetails.isEnabled()) {
if (LOGGER.isWarnEnabled()) {
warnRequest("[用户已被停用: username={}]", username);
}
return errorMessage("用户已被停用");
}
doLoginSuccess(userDetails);
onLoginSuccess(username, true);
JSONObject session = buildSession();
if (LOGGER.isInfoEnabled()) {
infoRequest("[用户成功登入: session={}]", session);
}
return objectResult(session);
}
Aggregations