和第三方单点时需要将门户的 token 传给前端单点的链接,如
http://前端服务器地址:端口/path路径/#/sd-thirdparty-login?token参数名=token参数值
当访问前端单点链接时,前端代码会自动将门户传过来的 token,传给单点接口,
http://后台服务器/path路径/api/thirdparty-login?token参数名=token参数值
该接口返回给前端的值最终应该是
{"access_token":"eyJhbdRr0lgw","expires_in":120,"refresh_token":"eyJhbGhEdkI8","expires_refresh":1200}
该接口的逻辑实现见文档或咨询后台开发人员:http://172.20.97.78:8989/webdoc/view/Pub2c94e1ce71a61e8101759d3046d530ef.html
在单点的链接后面添加参数 redirect,值为需要跳转的前端路由。比如待办的路由为/sd-webflow/todo-pages/26916 如:
通常情况下,token 或者路由可能会包含特殊字符,我们需要将参数 encodeURIComponent 处理一下,如
http://前端服务器地址:端口/path路径/#/sd-thirdparty-login?token参数名=tes%3D1%257&redirect=%2Fsd-webflow%2Ftodo-pages%2F26916
在原单点链接的基础上,加上兼职 srcTrustId 即可,如
http://前端服务器地址:端口/path路径/?srcTrustId=JZ651#/sd-thirdparty-login?token参数名=tes%3D1%257&redirect=%2Fsd-webflow%2Ftodo-pages%2F26916
并且后台单点接口还是返回主身份的 jwt token,所以只要加上兼职 srcTrustId 就行了,其他没有任何变化
这样单点后,前端自动会跳转对应的页面了,不需要写其他代码