oauth.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!DOCTYPE html>
  2. <html style="height: 100%;">
  3. <head lang="en">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. <meta charset="UTF-8">
  6. <title></title>
  7. <link rel="stylesheet" type="text/css" href="res/css/style.css" charset="UTF-8" />
  8. <link rel="stylesheet" href="res/css/mBoxNotice.css" charset="UTF-8" />
  9. <link rel="stylesheet" href="res/css/mBoxTooltip.css" charset="UTF-8" />
  10. <!--<script src="res/framework/mootools/mootools-core-1.4.5-full-nocompat.js"></script>-->
  11. <!--<script src="res/framework/mootools/mootools-more-1.4.0.1-all_2.js"></script>-->
  12. <script src="res/framework/mootools/mootools-1.6.0.min.js"></script>
  13. <script src="res/common.js?v=1.0.6"></script>
  14. <script>
  15. debugger;
  16. layout = window.layout || {};
  17. layout.desktop = layout;
  18. var locate = window.location;
  19. var protocol = locate.protocol;
  20. var href = locate.href;
  21. var uri = new URI(href);
  22. var oauth = uri.getData("oauth");
  23. var redirect = uri.getData("redirect");
  24. var code = uri.getData("code");
  25. var method = uri.getData("method");
  26. layout.load = function () {
  27. debugger;
  28. // layout.authentication = new MWF.xDesktop.Authentication({
  29. // "onLogin": layout.loadOauth.bind(layout)
  30. // });
  31. //
  32. // layout.authentication.isAuthenticated(function (json) {
  33. // layout.loadOauth();
  34. // //this.user = json.data;
  35. // }.bind(this), function () {
  36. // layout.loadOauth();
  37. // //layout.authentication.loadLogin($("layout"));
  38. // }.bind(this));
  39. if (code){
  40. layout.loginOauth();
  41. }else if(oauth){
  42. layout.loadOauth();
  43. }
  44. };
  45. layout.loginOauth = function () {
  46. var r = protocol+"//"+location.host+location.pathname;
  47. r = r+"?oauth="+oauth;
  48. if (redirect) r = r+"&redirect="+redirect;
  49. var action = MWF.Actions.get("x_organization_assemble_authentication");
  50. var logMethod = method || "loginOauthServer";
  51. action[logMethod](oauth, code, encodeURIComponent(r), function(){
  52. if (method==="oauthBind"){
  53. alert("用户绑定已成功!");
  54. window.close();
  55. }else{
  56. if (redirect){
  57. window.location = redirect;
  58. }else{
  59. window.location = "/";
  60. }
  61. }
  62. }.bind(this));
  63. };
  64. layout.loadOauth = function () {
  65. debugger;
  66. var action = MWF.Actions.get("x_organization_assemble_authentication");
  67. action.getOauthServer(oauth, function(json){
  68. var url = json.data.authAddress;
  69. var p = json.data.authParameter;
  70. var r = protocol+"//"+location.host+location.pathname;
  71. r = r+"?oauth="+oauth;
  72. if (method) r = r+"&method="+method;
  73. if (redirect) r = r+"&redirect="+redirect;
  74. p = (p) ? p+"&redirect_uri="+encodeURIComponent(r) : "&redirect_uri="+encodeURIComponent(r);
  75. url = (url.indexOf("?"===-1)) ? url+"?"+p : url+"&"+p;
  76. window.location = url;
  77. }.bind(this));
  78. };
  79. COMMON.setContentPath("/x_desktop");
  80. COMMON.AjaxModule.load("mwf", function(){
  81. MWF.defaultPath = "/x_desktop"+MWF.defaultPath;
  82. MWF.loadLP("zh-cn");
  83. MWF.require("MWF.xDesktop.Common", null, false);
  84. MWF.require("MWF.xAction.RestActions", null, false);
  85. COMMON.AjaxModule.load("/x_desktop/res/framework/mootools/plugin/mBox.Notice.js", null, false);
  86. COMMON.AjaxModule.load("/x_desktop/res/framework/mootools/plugin/mBox.Tooltip.js", null, false);
  87. MWF.getJSON("res/config/config.json", function (config) {
  88. layout.config = config;
  89. MWF.xDesktop.getServiceAddress(config, function (service, center) {
  90. layout.serviceAddressList = service;
  91. layout.centerServer = center;
  92. layout.load();
  93. }.bind(this));
  94. }.bind(this));
  95. // MWF.require("MWF.xDesktop.Layout", function() {
  96. // MWF.require("MWF.xDesktop.Authentication", null, false);
  97. // MWF.getJSON("res/config/config.json", function (config) {
  98. // layout.config = config;
  99. // MWF.xDesktop.getServiceAddress(config, function (service, center) {
  100. // layout.serviceAddressList = service;
  101. // layout.centerServer = center;
  102. // layout.load();
  103. // }.bind(this));
  104. // });
  105. //
  106. //
  107. // });
  108. });
  109. </script>
  110. </head>
  111. <body>
  112. <!--<body bgcolor="#faebd7" bgcolor="#ffc0cb" style="height: 100%; overflow: auto; margin:0px; background-size: cover; background-image: url(res/mwf4/package/xDesktop/$Layout/default/desktop.jpg);">-->
  113. <!--<div id="layout" style="overflow: auto; height:100%"></div>-->
  114. </body>
  115. </html>