smapsso.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. <meta charset="UTF-8">
  6. <title>登录中...</title>
  7. <script src="../o2_core/o2.min.js"></script>
  8. <script src="js/sso.min.js"></script>
  9. <script>
  10. o2.addReady(function(){
  11. o2.JSON.get("res/config/config.json", function(config){
  12. if (config.proxyCenterEnable){
  13. if (o2.typeOf(config.center)==="array"){
  14. config.center.forEach(function(c){
  15. c.port = window.location.port || 80;
  16. })
  17. }else{
  18. config.port = window.location.port || 80;
  19. }
  20. }
  21. layout.config = config;
  22. getServiceAddress(config, function(){
  23. var locate = window.location;
  24. var protocol = locate.protocol;
  25. var addressObj = layout.serviceAddressList["x_organization_assemble_authentication"];
  26. var defaultPort = layout.config.app_protocol==='https' ? "443" : "80";
  27. var appPort = addressObj.port || window.location.port;
  28. var address = protocol+"//"+(addressObj.host || window.location.hostname)+((!appPort || appPort.toString()===defaultPort) ? "" : ":"+appPort)+"/z_sso_control/jaxrs/sso/smplogin";
  29. var uri = new URI(window.location.toString());
  30. var xtoken = uri.getData("SMAP_SESSION_DATA");
  31. var appID = uri.getData("appID");
  32. var uniqueId = uri.getData("uniqueId");
  33. var flushPortalUrl = uri.getData("flushPortalUrl") || "";
  34. if( flushPortalUrl && flushPortalUrl.indexOf("%2F") === -1 ){
  35. flushPortalUrl = encodeURIComponent(flushPortalUrl);
  36. }
  37. var redirect = uri.getData("redirect");
  38. redirect = redirect + "&uniqueId=" + uniqueId + "&flushPortalUrl="+flushPortalUrl;
  39. var nav = uri.getData("nav");
  40. if(nav)redirect = redirect + "&nav=" + nav;
  41. if (xtoken){
  42. var res = new Request.JSON({
  43. url: o2.filterUrl(address+"?SMAP_SESSION_DATA="+encodeURIComponent(xtoken)+"&appID="+appID+"&date="+(new Date()).getTime()),
  44. secure: false,
  45. method: "GET",
  46. noCache: true,
  47. withCredentials: true,
  48. onSuccess: function(responseJSON, responseText){
  49. var result = responseJSON.data.value;
  50. if(result){
  51. if (redirect){
  52. window.location = redirect;
  53. }else{
  54. window.location = "/";
  55. }
  56. }else{
  57. $("ssoerror").set("html","单点失败!"+responseJSON.message);
  58. $("ssoerror").show();
  59. }
  60. }.bind(this),
  61. onFailure: function(xhr){
  62. $("ssoerror").show();
  63. }.bind(this),
  64. onError: function(text, error){
  65. $("ssoerror").show();
  66. }.bind(this)
  67. });
  68. res.send();
  69. }else{
  70. $("ssoerror").set("html","单点失败,认证token为空!");
  71. $("ssoerror").show();
  72. }
  73. });
  74. });
  75. });
  76. </script>
  77. </head>
  78. <body style="background: rgb(239, 239, 244);">
  79. <div id="ssoerror" style="text-align:center;display:none;">单点失败,请联系管理员!</div>
  80. </body>
  81. </html>