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.1.7"></script>
  14. <script>
  15. layout = window.layout || {};
  16. layout.desktop = layout;
  17. var locate = window.location;
  18. var protocol = locate.protocol;
  19. var href = locate.href;
  20. var uri = new URI(href);
  21. var oauth = uri.getData("oauth");
  22. var redirect = uri.getData("redirect");
  23. var code = uri.getData("code");
  24. var method = uri.getData("method");
  25. layout.load = function () {
  26. // layout.authentication = new MWF.xDesktop.Authentication({
  27. // "onLogin": layout.loadOauth.bind(layout)
  28. // });
  29. //
  30. // layout.authentication.isAuthenticated(function (json) {
  31. // layout.loadOauth();
  32. // //this.user = json.data;
  33. // }.bind(this), function () {
  34. // layout.loadOauth();
  35. // //layout.authentication.loadLogin($("layout"));
  36. // }.bind(this));
  37. if (code){
  38. layout.loginOauth();
  39. }else if(oauth){
  40. layout.loadOauth();
  41. }
  42. };
  43. layout.loginOauth = function () {
  44. var r = protocol+"//"+location.host+location.pathname;
  45. r = r+"?oauth="+oauth;
  46. if (redirect) r = r+"&redirect="+redirect;
  47. var action = MWF.Actions.get("x_organization_assemble_authentication");
  48. var logMethod = method || "loginOauthServer";
  49. action[logMethod](oauth, code, encodeURIComponent(r), function(){
  50. if (method==="oauthBind"){
  51. alert("用户绑定已成功!");
  52. window.close();
  53. }else{
  54. if (redirect){
  55. window.location = redirect;
  56. }else{
  57. window.location = "/";
  58. }
  59. }
  60. }.bind(this));
  61. };
  62. layout.loadOauth = function () {
  63. var action = MWF.Actions.get("x_organization_assemble_authentication");
  64. action.getOauthServer(oauth, function(json){
  65. var url = json.data.authAddress;
  66. var p = json.data.authParameter;
  67. var r = protocol+"//"+location.host+location.pathname;
  68. r = r+"?oauth="+oauth;
  69. if (method) r = r+"&method="+method;
  70. if (redirect) r = r+"&redirect="+redirect;
  71. p = (p) ? p+"&redirect_uri="+encodeURIComponent(r) : "&redirect_uri="+encodeURIComponent(r);
  72. url = (url.indexOf("?"===-1)) ? url+"?"+p : url+"&"+p;
  73. window.location = url;
  74. }.bind(this));
  75. };
  76. COMMON.setContentPath("/x_desktop");
  77. COMMON.AjaxModule.load("mwf", function(){
  78. MWF.defaultPath = "/x_desktop"+MWF.defaultPath;
  79. MWF.loadLP("zh-cn");
  80. MWF.require("MWF.xDesktop.Common", null, false);
  81. MWF.require("MWF.xAction.RestActions", null, false);
  82. COMMON.AjaxModule.load("/x_desktop/res/framework/mootools/plugin/mBox.Notice.js", null, false);
  83. COMMON.AjaxModule.load("/x_desktop/res/framework/mootools/plugin/mBox.Tooltip.js", null, false);
  84. MWF.getJSON("res/config/config.json", function (config) {
  85. layout.config = config;
  86. MWF.xDesktop.getServiceAddress(config, function (service, center) {
  87. layout.serviceAddressList = service;
  88. layout.centerServer = center;
  89. layout.load();
  90. }.bind(this));
  91. }.bind(this));
  92. // MWF.require("MWF.xDesktop.Layout", function() {
  93. // MWF.require("MWF.xDesktop.Authentication", null, false);
  94. // MWF.getJSON("res/config/config.json", function (config) {
  95. // layout.config = config;
  96. // MWF.xDesktop.getServiceAddress(config, function (service, center) {
  97. // layout.serviceAddressList = service;
  98. // layout.centerServer = center;
  99. // layout.load();
  100. // }.bind(this));
  101. // });
  102. //
  103. //
  104. // });
  105. });
  106. </script>
  107. </head>
  108. <body>
  109. <!--<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);">-->
  110. <!--<div id="layout" style="overflow: auto; height:100%"></div>-->
  111. </body>
  112. </html>