登录不使用缓存,该缓存命中率不高,同时解决由于由于缓存引起密码无法更改的问题

This commit is contained in:
OPGame
2019-09-23 20:14:04 +08:00
parent cfa0a1b5d3
commit 9a76de8092
7 changed files with 18 additions and 54 deletions

View File

@@ -63,10 +63,6 @@ public class SysLoginController {
*/
@PostMapping(value = "/sys/logout")
public ResponseEntity<String> logout() {
Cache cache = cacheManager.getCache("yami_sys_user");
if (cache != null) {
cache.evict(SecurityUtils.getSysUser().getUsername());
}
SecurityContextHolder.clearContext();
return ResponseEntity.ok().build();
}

View File

@@ -87,17 +87,17 @@ public class YamiTokenServices implements AuthorizationServerTokenServices, Reso
OAuth2AccessToken existingAccessToken = tokenStore.getAccessToken(authentication);
OAuth2RefreshToken refreshToken = null;
// 如果有token直接删除更新token避免出现缓存问题
if (existingAccessToken != null) {
if (existingAccessToken.getRefreshToken() != null) {
refreshToken = existingAccessToken.getRefreshToken();
// The token store could remove the refresh token when the
// access token is removed, but we want to
// be sure...
tokenStore.removeRefreshToken(refreshToken);
}
tokenStore.removeAccessToken(existingAccessToken);
}
// if (existingAccessToken != null) {
// if (existingAccessToken.getRefreshToken() != null) {
// refreshToken = existingAccessToken.getRefreshToken();
// // The token store could remove the refresh token when the
// // access token is removed, but we want to
// // be sure...
// tokenStore.removeRefreshToken(refreshToken);
// }
// tokenStore.removeAccessToken(existingAccessToken);
//
// }
// Only create a new refresh token if there wasn't an existing one
// associated with an expired access token.