smapsso.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 address = protocol+"//"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+"/z_sso_control/jaxrs/sso/smplogin";
  27. var uri = new URI(window.location.toString());
  28. var xtoken = uri.getData("SMAP_SESSION_DATA");
  29. var appID = uri.getData("appID");
  30. var uniqueId = uri.getData("uniqueId");
  31. var flushPortalUrl = uri.getData("flushPortalUrl") || "";
  32. if( flushPortalUrl && flushPortalUrl.indexOf("%2F") === -1 ){
  33. flushPortalUrl = encodeURIComponent(flushPortalUrl);
  34. }
  35. var redirect = uri.getData("redirect");
  36. redirect = redirect + "&uniqueId=" + uniqueId + "&flushPortalUrl="+flushPortalUrl;
  37. var nav = uri.getData("nav");
  38. if(nav)redirect = redirect + "&nav=" + nav;
  39. if (xtoken){
  40. var res = new Request.JSON({
  41. url: o2.filterUrl(address+"?SMAP_SESSION_DATA="+encodeURIComponent(xtoken)+"&appID="+appID+"&date="+(new Date()).getTime()),
  42. secure: false,
  43. method: "GET",
  44. noCache: true,
  45. withCredentials: true,
  46. onSuccess: function(responseJSON, responseText){
  47. var result = responseJSON.data.value;
  48. if(result){
  49. if (redirect){
  50. window.location = redirect;
  51. }else{
  52. window.location = "/";
  53. }
  54. }else{
  55. $("ssoerror").set("html","单点失败!"+responseJSON.message);
  56. $("ssoerror").show();
  57. }
  58. }.bind(this),
  59. onFailure: function(xhr){
  60. $("ssoerror").show();
  61. }.bind(this),
  62. onError: function(text, error){
  63. $("ssoerror").show();
  64. }.bind(this)
  65. });
  66. res.send();
  67. }else{
  68. $("ssoerror").set("html","单点失败,认证token为空!");
  69. $("ssoerror").show();
  70. }
  71. });
  72. });
  73. });
  74. </script>
  75. </head>
  76. <body style="background: rgb(239, 239, 244);">
  77. <div id="ssoerror" style="text-align:center;display:none;">单点失败,请联系管理员!</div>
  78. </body>
  79. </html>