mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-03 17:42:20 +08:00
fix: 未登录会员是否登录判断错误问题修复
This commit is contained in:
parent
7d20277b59
commit
cb9dff16f4
@ -44,7 +44,7 @@ public class SpuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取秒杀商品列表")
|
@ApiOperation(value = "获取秒杀商品列表")
|
||||||
@GetMapping("/seckilling_list")
|
@GetMapping("/seckillList")
|
||||||
public Result<List<SeckillingSpuVO>> listSeckillingSpu() {
|
public Result<List<SeckillingSpuVO>> listSeckillingSpu() {
|
||||||
List<SeckillingSpuVO> list = spuService.listSeckillingSpu();
|
List<SeckillingSpuVO> list = spuService.listSeckillingSpu();
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
|
@ -162,8 +162,8 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加用户浏览历史记录
|
// 添加用户浏览历史记录
|
||||||
Long loginUserId = SecurityUtils.getMemberId();
|
Long memberId = SecurityUtils.getMemberId();
|
||||||
if (loginUserId != null) {
|
if (memberId != null) {
|
||||||
ProductHistoryVO vo = new ProductHistoryVO();
|
ProductHistoryVO vo = new ProductHistoryVO();
|
||||||
vo.setId(goodsInfo.getId());
|
vo.setId(goodsInfo.getId());
|
||||||
vo.setName(goodsInfo.getName());
|
vo.setName(goodsInfo.getName());
|
||||||
|
@ -70,7 +70,7 @@ public class SecurityUtils {
|
|||||||
*/
|
*/
|
||||||
public static Set<String> getRoles() {
|
public static Set<String> getRoles() {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication!=null && CollectionUtil.isNotEmpty(authentication.getAuthorities())) {
|
if (authentication != null && CollectionUtil.isNotEmpty(authentication.getAuthorities())) {
|
||||||
Set<String> roles = authentication.getAuthorities()
|
Set<String> roles = authentication.getAuthorities()
|
||||||
.stream()
|
.stream()
|
||||||
.map(item -> StrUtil.removePrefix(item.getAuthority(), "ROLE_"))
|
.map(item -> StrUtil.removePrefix(item.getAuthority(), "ROLE_"))
|
||||||
@ -111,8 +111,13 @@ public class SecurityUtils {
|
|||||||
|
|
||||||
public static Map<String, Object> getTokenAttributes() {
|
public static Map<String, Object> getTokenAttributes() {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
JwtAuthenticationToken jwtAuthenticationToken = (JwtAuthenticationToken) authentication;
|
if (authentication != null) {
|
||||||
Map<String, Object> tokenAttributes = jwtAuthenticationToken.getTokenAttributes();
|
if (authentication instanceof JwtAuthenticationToken) {
|
||||||
return tokenAttributes;
|
JwtAuthenticationToken jwtAuthenticationToken = (JwtAuthenticationToken) authentication;
|
||||||
|
Map<String, Object> tokenAttributes = jwtAuthenticationToken.getTokenAttributes();
|
||||||
|
return tokenAttributes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.EMPTY_MAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user