auth2_callback.tpl 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8">
  5. <link rel="shortcut icon" href="{{cdnimg "/static/favicon.ico"}}">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  7. <meta name="renderer" content="webkit" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <meta name="author" content="MinDoc" />
  10. <title>用户登录 - Powered by MinDoc</title>
  11. <meta name="keywords" content="MinDoc,文档在线管理系统,WIKI,wiki,wiki在线,文档在线管理,接口文档在线管理,接口文档管理">
  12. <meta name="description" content="MinDoc文档在线管理系统 {{.site_description}}">
  13. <!-- Bootstrap -->
  14. <link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
  15. <link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet">
  16. <link href="{{cdncss "/static/css/main.css" "version"}}" rel="stylesheet">
  17. <style type="text/css">
  18. .login > .login-body {
  19. text-align: center;
  20. padding-top: 1.5em;
  21. }
  22. .login > .login-body > a > strong:hover {
  23. border-bottom: 1px solid #337ab7;
  24. }
  25. .login > .login-body > a > strong {
  26. font-size: 1.5em;
  27. vertical-align: middle;
  28. padding: 0.5em;
  29. }
  30. .bind-existed-form > .form-group {
  31. margin: auto 1.5em;
  32. margin-top: 1em;
  33. }
  34. </style>
  35. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  36. <script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}"></script>
  37. <script type="text/javascript">
  38. window.bind_existed = {{ .bind_existed }};
  39. window.user_info_json = {{ .user_info_json }};
  40. window.server_error_msg = "{{ .error_msg }}";
  41. window.home_url = "{{ .BaseUrl }}";
  42. window.account_bind = "{{urlfor "AccountController.Auth2BindAccount" ":app" .app}}";
  43. window.account_auto_create = "{{urlfor "AccountController.Auth2AutoAccount" ":app" .app}}";
  44. </script>
  45. </head>
  46. <body class="manual-container">
  47. <header class="navbar navbar-static-top smart-nav navbar-fixed-top manual-header" role="banner">
  48. <div class="container">
  49. <div class="navbar-header col-sm-12 col-md-6 col-lg-5">
  50. <a href="{{.BaseUrl}}" class="navbar-brand">{{.SITE_NAME}}</a>
  51. </div>
  52. </div>
  53. </header>
  54. <div class="container manual-body">
  55. <div class="row login">
  56. <div class="login-body">
  57. 返回 <a href="{{ .BaseUrl }}"><strong>首页</strong></a>
  58. </div>
  59. </div>
  60. <div class="clearfix"></div>
  61. <script type="text/x-template" id="bind-existed-template">
  62. <div role="form" class="bind-existed-form">
  63. {{ .xsrfdata }}
  64. <div class="form-group">
  65. <div class="input-group">
  66. <div class="input-group-addon">
  67. <i class="fa fa-user"></i>
  68. </div>
  69. <input type="text" class="form-control" placeholder="邮箱 / 用户名" name="account" id="account" autocomplete="off">
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <div class="input-group">
  74. <div class="input-group-addon">
  75. <i class="fa fa-lock"></i>
  76. </div>
  77. <input type="password" class="form-control" placeholder="密码" name="password" id="password" autocomplete="off">
  78. </div>
  79. </div>
  80. </div>
  81. </script>
  82. </div>
  83. {{template "widgets/footer.tpl" .}}
  84. <!-- Include all compiled plugins (below), or include individual files as needed -->
  85. <script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}" type="text/javascript"></script>
  86. <script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript"></script>
  87. <script type="text/javascript">
  88. function showBindAccount() {
  89. layer.confirm([
  90. '检测到当前登录企业微信未绑定已有账户, 是否需要绑定已有账户?<br />',
  91. '<ul style="padding-left: 1.2em;">',
  92. '<li>若已有账户, 请 <strong>去绑定</strong></li>',
  93. '<li>若没有现有账户, 请 <strong>忽略绑定</strong></li>',
  94. '</ul>'
  95. ].join(''), {
  96. title: "WIKI-绑定提示",
  97. move: false,
  98. area: 'auto',
  99. offset: 'auto',
  100. icon: 3,
  101. btn: ['去绑定','忽略绑定'],
  102. }, function(index, layero){
  103. // layer.close(index);
  104. // layer.msg(window.home_url);
  105. // TODO: 现有账户[用户名+密码]查询现有账户 依据Session[user_info]绑定更新现有账户
  106. console.log("yes");
  107. layer.open({
  108. title: "绑定已有账户",
  109. type: 1,
  110. move: false,
  111. area: 'auto',
  112. offset: 'auto',
  113. content: $('#bind-existed-template').html(),
  114. btn: ['绑定','取消'],
  115. yes: function(index, layero){
  116. $.ajax({
  117. url: window.account_bind,
  118. type: 'POST',
  119. beforeSend: function(request) {
  120. request.setRequestHeader("X-Xsrftoken", $('.bind-existed-form input[name="_xsrf"]').val());
  121. },
  122. data: {
  123. account: $('#account').val(),
  124. password: $('#password').val()
  125. },
  126. dataType: 'json',
  127. success: function(data) {
  128. if(data.errcode == 0) {
  129. layer.close(index);
  130. // layer.msg(JSON.stringify(data), {icon: 1, time: 15500});
  131. window.location.href = window.home_url;
  132. }
  133. else {
  134. layer.msg(data.message, {icon: 5, time: 3500});
  135. }
  136. },
  137. error: function(data) {
  138. console.log(data);
  139. }
  140. });
  141. return false;
  142. },
  143. cancel: function(index, layero){
  144. // return false; // 不关闭
  145. layer.close(index);
  146. window.location.href = window.home_url;
  147. }
  148. });
  149. }, function(index){
  150. /*
  151. // TODO: 依据Session[user_info]创建新账户
  152. console.log("no");
  153. var msg = '';
  154. // msg = "<pre>" + JSON.stringify(window.location, null, 4) + "</pre>";
  155. msg = "<pre>" + JSON.stringify(window.user_info_json, null, 4) + "</pre>";
  156. // msg = "<pre>" + window.user_info_json + "</pre>";
  157. layer.open({
  158. title: "Degug-UserInfo",
  159. type: 1,
  160. skin: 'layui-layer-rim',
  161. move: false,
  162. area: 'auto',
  163. offset: 'auto',
  164. content: msg
  165. });
  166. */
  167. $.ajax({
  168. url: window.account_auto_create,
  169. type: 'GET',
  170. beforeSend: function(request) {
  171. request.setRequestHeader("X-Xsrftoken", $('.bind-existed-form input[name="_xsrf"]').val());
  172. },
  173. data: {},
  174. dataType: 'json',
  175. success: function(data) {
  176. if(data.errcode == 0) {
  177. layer.close(index);
  178. layer.msg(JSON.stringify(data), {icon: 1, time: 15500});
  179. window.location.href = window.home_url;
  180. }
  181. else {
  182. layer.msg(data.message, {icon: 5, time: 3500});
  183. }
  184. },
  185. error: function(data) {
  186. console.log(data);
  187. }
  188. });
  189. return false;
  190. });
  191. }
  192. $(document).ready(function () {
  193. $('#debug-panel').val($('html').html());
  194. if (!!window.server_error_msg && window.server_error_msg.length > 0) {
  195. layer.msg(window.server_error_msg, {icon: 5, time: 3500});
  196. } else {
  197. if (window.bind_existed === false) {
  198. showBindAccount();
  199. } else {
  200. // alert(typeof window.bind_existed);
  201. // alert('_' + window.bind_existed + '_');
  202. window.location.href = window.home_url;
  203. }
  204. }
  205. });
  206. </script>
  207. </body>
  208. </html>