处理mongo登录问题
This commit is contained in:
parent
73939e91d7
commit
fd75dbef6c
@ -29,12 +29,12 @@ public class LoginUser implements UserDetails, CredentialsContainer {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1399973719726626183L;
|
private static final long serialVersionUID = 1399973719726626183L;
|
||||||
private String password;
|
private String password;
|
||||||
private final String username;
|
private String username;
|
||||||
private final boolean accountNonExpired;
|
private boolean accountNonExpired;
|
||||||
private final boolean accountNonLocked;
|
private boolean accountNonLocked;
|
||||||
private final boolean credentialsNonExpired;
|
private boolean credentialsNonExpired;
|
||||||
private Set<GrantedAuthority> authorities;
|
private Set<GrantedAuthority> authorities;
|
||||||
private final boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
private String userId;
|
private String userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
@ -57,6 +57,10 @@ public class LoginUser implements UserDetails, CredentialsContainer {
|
|||||||
*/
|
*/
|
||||||
private Object expandData;
|
private Object expandData;
|
||||||
|
|
||||||
|
public LoginUser() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public LoginUser(String username, String password) {
|
public LoginUser(String username, String password) {
|
||||||
this(username, password, true, true, true, true);
|
this(username, password, true, true, true, true);
|
||||||
}
|
}
|
||||||
@ -74,11 +78,35 @@ public class LoginUser implements UserDetails, CredentialsContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountNonExpired(boolean accountNonExpired) {
|
||||||
|
this.accountNonExpired = accountNonExpired;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountNonLocked(boolean accountNonLocked) {
|
||||||
|
this.accountNonLocked = accountNonLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCredentialsNonExpired(boolean credentialsNonExpired) {
|
||||||
|
this.credentialsNonExpired = credentialsNonExpired;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAuthorities(Set<GrantedAuthority> authorities) {
|
public void setAuthorities(Set<GrantedAuthority> authorities) {
|
||||||
// this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));
|
// this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));
|
||||||
this.authorities = sortAuthorities(authorities);
|
this.authorities = sortAuthorities(authorities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<GrantedAuthority> getAuthorities() {
|
public Collection<GrantedAuthority> getAuthorities() {
|
||||||
return this.authorities;
|
return this.authorities;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@ public class RoleGrantedAuthorityBO implements GrantedAuthority {
|
|||||||
private List<String> updates;
|
private List<String> updates;
|
||||||
private List<String> queries;
|
private List<String> queries;
|
||||||
|
|
||||||
|
public RoleGrantedAuthorityBO() {
|
||||||
|
}
|
||||||
|
|
||||||
public RoleGrantedAuthorityBO(String roleId) {
|
public RoleGrantedAuthorityBO(String roleId) {
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
@ -130,4 +133,6 @@ public class RoleGrantedAuthorityBO implements GrantedAuthority {
|
|||||||
public void setQueries(List<String> queries) {
|
public void setQueries(List<String> queries) {
|
||||||
this.queries = queries;
|
this.queries = queries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import ink.wgink.service.user.service.IUserService;
|
|||||||
import ink.wgink.util.UUIDUtil;
|
import ink.wgink.util.UUIDUtil;
|
||||||
import ink.wgink.util.date.DateUtil;
|
import ink.wgink.util.date.DateUtil;
|
||||||
import ink.wgink.util.request.RequestUtil;
|
import ink.wgink.util.request.RequestUtil;
|
||||||
|
import ink.wgink.util.thread.CachedThreadPoolUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -176,12 +177,14 @@ public class UserLoginService {
|
|||||||
* @param userId
|
* @param userId
|
||||||
*/
|
*/
|
||||||
public void updateUserLoginInfo(String userId, String userName, String loginType) {
|
public void updateUserLoginInfo(String userId, String userName, String loginType) {
|
||||||
LOG.debug("更新登录信息");
|
|
||||||
String address = RequestUtil.getRequestIp();
|
String address = RequestUtil.getRequestIp();
|
||||||
String currentTime = DateUtil.getTime();
|
String currentTime = DateUtil.getTime();
|
||||||
|
CachedThreadPoolUtil.execute(() -> {
|
||||||
|
LOG.debug("更新登录信息");
|
||||||
updateLoginInfo(userId, address, currentTime);
|
updateLoginInfo(userId, address, currentTime);
|
||||||
LOG.debug("新增登录日志");
|
LOG.debug("新增登录日志");
|
||||||
saveLoginLogger(userId, userName, loginType, address, currentTime);
|
saveLoginLogger(userId, userName, loginType, address, currentTime);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ public class MongoLoginUserServiceImpl extends DefaultBaseService implements IMo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginUser getByUsername(String username) {
|
public LoginUser getByUsername(String username) {
|
||||||
return mongoTemplate.findOne(new Query().addCriteria(Criteria.where("userUsername").is(username)), LoginUser.class, COLLECTION_NAME);
|
return mongoTemplate.findOne(new Query().addCriteria(Criteria.where("username").is(username)), LoginUser.class, COLLECTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user