You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class StpUserUtil {
public static final String TYPE = "user";
//重写stpLogic自定义tokenName
public static StpLogic stpLogic = new StpLogic("user") {
@Override
public String splicingKeyTokenName() {
return super.splicingKeyTokenName() + "-user";
}
};
}
@Configuration
public class SaTokenJwtConfig {
@Bean
public StpLogic getStpLogicJwt() {
return new StpLogicJwtForSimple();
}
@Autowired
public void setUserStpLogic() {
StpUserUtil.setStpLogic(new StpLogicJwtForSimple(StpUserUtil.TYPE); //问题所在
}
}
对以下问题有疑问
在尝试用使用多账户时,按照文档集成了jwt功能,未手动为自定义 StpUserUtil 注入 StpLogicJwtFoxXxx 实现时,修改的tokenName可以生效。当手动注入后出现tokenName被覆盖的问题。
StpUserUtil代码样例,代码参考自同端多登陆:
在全局配置中添加jwt配置,参考自在多账户模式中集成 jwt。
具体问题
StpLogicJwtForSimple 通过 StpUserUtil 中的 setStpLogic 方法覆盖了原有 StpUserUtil (StpUtil) 类中自定义的 stpLogic,导致自定义 tokenName 失效,原代码参考自文档样例 码云 StpUserUtil.java
解决方法
StpLogicJwtForSimple 继承自 StpLogic,因此需要在手动为 StpUserUtil 注入 StpLogicJwtFoxXxx 实现时,通过 StpLogicJwtForSimple 的 splicingKeyTokenName 方法重写 tokenName
The text was updated successfully, but these errors were encountered: