修复 前后端分离模式下 集成 sso 的 demo 示例错误代码

This commit is contained in:
click33 2024-05-17 11:41:42 +08:00
parent a0faf303d8
commit 40b01aba00
4 changed files with 11 additions and 16 deletions

View File

@ -15,7 +15,7 @@
<script type="text/javascript">
// 后端接口地址
var baseUrl = "http://sa-sso-client1.com:9001";
var baseUrl = "http://sa-sso-client1.com:9002";
// 查询当前会话是否登录
$.ajax({

View File

@ -16,7 +16,7 @@
<script type="text/javascript">
// 后端接口地址
var baseUrl = "http://sa-sso-client1.com:9001";
var baseUrl = "http://sa-sso-client1.com:9002";
var back = getParam('back', '/');
var ticket = getParam('ticket');

View File

@ -1,5 +1,6 @@
package com.pj.h5;
import cn.dev33.satoken.sso.model.SaCheckTicketResult;
import cn.dev33.satoken.sso.processor.SaSsoClientProcessor;
import cn.dev33.satoken.sso.template.SaSsoUtil;
import cn.dev33.satoken.stp.StpUtil;
@ -30,15 +31,12 @@ public class H5Controller {
return SaResult.data(serverAuthUrl);
}
// 根据ticket进行登录
// 根据ticket进行登录
@RequestMapping("/sso/doLoginByTicket")
public SaResult doLoginByTicket(String ticket) {
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
if(loginId != null) {
StpUtil.login(loginId);
return SaResult.data(StpUtil.getTokenValue());
}
return SaResult.error("无效ticket" + ticket);
SaCheckTicketResult ctr = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
StpUtil.login(ctr.loginId, ctr.remainSessionTimeout);
return SaResult.data(StpUtil.getTokenValue());
}
// 全局异常拦截

View File

@ -27,15 +27,12 @@ public class H5Controller {
return SaResult.data(serverAuthUrl);
}
// 根据ticket进行登录
// 根据ticket进行登录
@RequestMapping("/sso/doLoginByTicket")
public SaResult doLoginByTicket(String ticket) {
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
if(loginId != null) {
StpUtil.login(loginId);
return SaResult.data(StpUtil.getTokenValue());
}
return SaResult.error("无效ticket" + ticket);
SaCheckTicketResult ctr = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
StpUtil.login(ctr.loginId, ctr.remainSessionTimeout);
return SaResult.data(StpUtil.getTokenValue());
}
// 全局异常拦截