oauth.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.0.8"></script>
  13. <script src="../o2_core/compatible.min.js?v=2.0.8"></script>
  14. <script src="../o2_lib/Decimal.js"></script>
  15. <script>
  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. // layout.authentication = new MWF.xDesktop.Authentication({
  28. // "onLogin": layout.loadOauth.bind(layout)
  29. // });
  30. //
  31. // layout.authentication.isAuthenticated(function (json) {
  32. // layout.loadOauth();
  33. // //this.user = json.data;
  34. // }.bind(this), function () {
  35. // layout.loadOauth();
  36. // //layout.authentication.loadLogin($("layout"));
  37. // }.bind(this));
  38. if (code){
  39. layout.loginOauth();
  40. }else if(oauth){
  41. layout.loadOauth();
  42. }
  43. };
  44. layout.loginOauth = function () {
  45. var r = protocol+"//"+location.host+location.pathname;
  46. r = r+"?oauth="+oauth;
  47. if (redirect) r = r+"&redirect="+redirect;
  48. var action = MWF.Actions.get("x_organization_assemble_authentication");
  49. var logMethod = method || "loginOauthServer";
  50. action[logMethod](oauth, code, encodeURIComponent(r), function(){
  51. if (method==="oauthBind"){
  52. alert("用户绑定已成功!");
  53. window.close();
  54. }else{
  55. if (redirect){
  56. window.location = redirect;
  57. }else{
  58. window.location = "/";
  59. }
  60. }
  61. }.bind(this));
  62. };
  63. layout.loadOauth = function () {
  64. var action = MWF.Actions.get("x_organization_assemble_authentication");
  65. action.getOauthServer(oauth, function(json){
  66. var url = json.data.authAddress;
  67. var p = json.data.authParameter;
  68. var r = protocol+"//"+location.host+location.pathname;
  69. r = r+"?oauth="+oauth;
  70. if (method) r = r+"&method="+method;
  71. if (redirect) r = r+"&redirect="+redirect;
  72. p = (p) ? p+"&redirect_uri="+encodeURIComponent(r) : "&redirect_uri="+encodeURIComponent(r);
  73. url = (url.indexOf("?"===-1)) ? url+"?"+p : url+"&"+p;
  74. window.location = url;
  75. }.bind(this));
  76. };
  77. o2.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. o2.load(["../o2_lib/mootools/plugin/mBox.Notice.js", "../o2_lib/mootools/plugin/mBox.Tooltip.js"], {"sequence": true}, function(){
  83. o2.JSON.get("res/config/config.json", function (config) {
  84. layout.config = config;
  85. MWF.xDesktop.getServiceAddress(config, function (service, center) {
  86. layout.serviceAddressList = service;
  87. layout.centerServer = center;
  88. layout.load();
  89. }.bind(this));
  90. }.bind(this));
  91. });
  92. });
  93. </script>
  94. </head>
  95. <body>
  96. <!--<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);">-->
  97. <!--<div id="layout" style="overflow: auto; height:100%"></div>-->
  98. </body>
  99. </html>