oauth.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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="css/style.css" charset="UTF-8" />
  8. <link rel="stylesheet" href="css/mBoxNotice.css" charset="UTF-8" />
  9. <link rel="stylesheet" href="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="../o2_core/o2.min.js?v=2.2.1"></script>
  13. <script src="../o2_core/compatible.min.js?v=2.2.1"></script>
  14. <script src="../o2_lib/Decimal.js"></script>
  15. <script>
  16. o2.addReady(function(){
  17. layout = window.layout || {};
  18. layout.desktop = layout;
  19. o2.xDesktop = o2.xDesktop || {};
  20. var locate = window.location;
  21. var protocol = locate.protocol;
  22. var href = locate.href;
  23. var uri = new URI(href);
  24. var oauth = uri.getData("oauth");
  25. var redirect = uri.getData("redirect");
  26. var code = uri.getData("code");
  27. var method = uri.getData("method");
  28. layout.load = function () {
  29. // layout.authentication = new MWF.xDesktop.Authentication({
  30. // "onLogin": layout.loadOauth.bind(layout)
  31. // });
  32. //
  33. // layout.authentication.isAuthenticated(function (json) {
  34. // layout.loadOauth();
  35. // //this.user = json.data;
  36. // }.bind(this), function () {
  37. // layout.loadOauth();
  38. // //layout.authentication.loadLogin($("layout"));
  39. // }.bind(this));
  40. if (code){
  41. layout.loginOauth();
  42. }else if(oauth){
  43. layout.loadOauth();
  44. }
  45. };
  46. layout.loginOauth = function () {
  47. var r = protocol+"//"+location.host+location.pathname;
  48. r = r+"?oauth="+oauth;
  49. if (redirect) r = r+"&redirect="+redirect;
  50. var action = MWF.Actions.get("x_organization_assemble_authentication");
  51. var logMethod = method || "loginOauthServer";
  52. action[logMethod](oauth, code, encodeURIComponent(r), function(){
  53. if (method==="oauthBind"){
  54. alert("用户绑定已成功!");
  55. window.close();
  56. }else{
  57. if (redirect){
  58. window.location = redirect;
  59. }else{
  60. window.location = "/";
  61. }
  62. }
  63. }.bind(this));
  64. };
  65. layout.loadOauth = function () {
  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. //o2.load("mwf", function(){
  80. //MWF.defaultPath = "/x_desktop"+MWF.defaultPath;
  81. MWF.loadLP("zh-cn");
  82. MWF.require("MWF.xDesktop.Common", null, false);
  83. MWF.require("MWF.xAction.RestActions", null, false);
  84. o2.load(["../o2_lib/mootools/plugin/mBox.Notice.js", "../o2_lib/mootools/plugin/mBox.Tooltip.js"], {"sequence": true}, function(){
  85. o2.JSON.get("res/config/config.json", function (config) {
  86. layout.config = config;
  87. MWF.xDesktop.getServiceAddress(config, function (service, center) {
  88. layout.serviceAddressList = service;
  89. layout.centerServer = center;
  90. layout.load();
  91. }.bind(this));
  92. }.bind(this));
  93. });
  94. //});
  95. });
  96. </script>
  97. <script src="../o2_lib/mootools/mootools-1.6.0.min.js"></script>
  98. </head>
  99. <body>
  100. <!--<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);">-->
  101. <!--<div id="layout" style="overflow: auto; height:100%"></div>-->
  102. </body>
  103. </html>