login-update-password.ftl 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name='viewport' content='width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no' />
  6. <title>${realm.displayName}</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. }
  12. html,
  13. body {
  14. width: 100%;
  15. height: 100%;
  16. }
  17. body {
  18. box-sizing: border-box;
  19. -moz-osx-font-smoothing: grayscale;
  20. -webkit-font-smoothing: antialiased;
  21. text-rendering: optimizeLegibility;
  22. font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
  23. background-color: #FFFFFF;
  24. }
  25. *,
  26. *::before,
  27. *::after {
  28. box-sizing: inherit;
  29. }
  30. a {
  31. border: none;
  32. outline: none;
  33. text-decoration: none;
  34. -webkit-touch-callout: none;
  35. -webkit-tap-highlight-color: transparent;
  36. }
  37. .c-login {
  38. display: flex;
  39. justify-content: center;
  40. align-items: center;
  41. min-height: 100%;
  42. width: 100%;
  43. }
  44. .c-login__main {
  45. flex: 1 0 auto;
  46. }
  47. .c-login-form {
  48. display: inline-flex;
  49. flex-direction: column;
  50. justify-content: center;
  51. align-items: center;
  52. padding: 0 0 40px;
  53. overflow: auto;
  54. }
  55. .c-login-form__header {
  56. color: #1C5CB0;
  57. font-size: 28px;
  58. font-weight: bold;
  59. text-align: center;
  60. }
  61. .c-login-form__tip {
  62. padding: 20px;
  63. height: 60px;
  64. }
  65. .c-login-form__tip .success {
  66. color: #67C23A;
  67. }
  68. .c-login-form__tip .warning {
  69. color: #E6A23C;
  70. }
  71. .c-login-form__tip .error {
  72. color: #F56C6C;
  73. }
  74. .c-login-form__tip .info {
  75. color: #409EFF;
  76. }
  77. .c-login-form__section {
  78. display: flex;
  79. flex-direction: column;
  80. align-items: center;
  81. }
  82. .c-login-form__wrapper {
  83. display: flex;
  84. align-items: center;
  85. }
  86. .c-login-form__label {
  87. width: 150px;
  88. margin-right: 20px;
  89. color: #333333;
  90. font-size: 16px;
  91. text-align: right;
  92. }
  93. .c-login-form__label::before {
  94. content: "*";
  95. color: #FF0000;
  96. font-size: 14px;
  97. }
  98. .c-login-form__input {
  99. padding: 0 10px;
  100. width: 320px;
  101. height: 30px;
  102. font-size: 14px;
  103. line-height: 30px;
  104. border: 1px solid #C4C4C4;
  105. outline: none;
  106. }
  107. .c-login-form__input.password {
  108. -webkit-text-security: disc;
  109. }
  110. .c-login-form__error {
  111. display: inline-block;
  112. width: 320px;
  113. height: 30px;
  114. margin-left: 170px;
  115. color: #F56C6C;
  116. font-size: 12px;
  117. line-height: 24px;
  118. white-space: nowrap;
  119. }
  120. .c-login-form__submit {
  121. display: inline-flex;
  122. justify-content: center;
  123. align-items: center;
  124. height: 40px;
  125. padding: 0 40px;
  126. margin-top: 60px;
  127. color: #ffffff;
  128. font-size: 18px;
  129. border: none;
  130. background-color: #1C5CB0;
  131. border-radius: 8px;
  132. cursor: pointer;
  133. }
  134. .c-login-form__submit[disabled] {
  135. background-color: #C4C4C4;
  136. }
  137. </style>
  138. </head>
  139. <body>
  140. <div class="c-login">
  141. <form
  142. id="loginForm"
  143. class="c-login__main c-login-form"
  144. action="${url.loginAction}"
  145. method="post"
  146. onsubmit="return false;"
  147. >
  148. <div class="c-login-form__header">修改密码</div>
  149. <div class="c-login-form__tip">
  150. <#if !messagesPerField.existsError('password','password-confirm') && message?has_content && !isAppInitiatedAction??>
  151. <span class="${message.type}">${kcSanitize(message.summary)?no_esc}</span>
  152. </#if>
  153. </div>
  154. <div class="c-login-form__tip">
  155. <span class="warning"> 至少包含数字、字符、小写字母、大写字母 字符范围:+_!@#$%^&amp;*.,?</span>
  156. </div>
  157. <input id="username" name="username" type="text" value="${username}" autocomplete="username" readonly="readonly" style="display:none;"/>
  158. <input id="password" name="password" type="password" autocomplete="current-password" style="display:none;"/>
  159. <div class="c-login-form__section">
  160. <div class="c-login-form__wrapper">
  161. <label
  162. for="passwordNewProxy"
  163. class="c-login-form__label"
  164. >
  165. 新密码:
  166. </label>
  167. <input
  168. id="passwordNewProxy"
  169. type="password"
  170. class="c-login-form__input"
  171. placeholder="请输入新密码"
  172. autocomplete="new-password"
  173. aria-autocomplete="none"
  174. >
  175. </div>
  176. <div class="c-login-form__error">
  177. <#if messagesPerField.existsError('password')>
  178. ${kcSanitize(messagesPerField.get('password'))?no_esc}
  179. </#if>
  180. </div>
  181. </div>
  182. <div class="c-login-form__section">
  183. <div class="c-login-form__wrapper">
  184. <label
  185. for="passwordConfirmProxy"
  186. class="c-login-form__label"
  187. >
  188. 确认新密码:
  189. </label>
  190. <input
  191. id="passwordConfirmProxy"
  192. type="password"
  193. class="c-login-form__input"
  194. placeholder="请输入新密码"
  195. autocomplete="new-password"
  196. aria-autocomplete="none"
  197. >
  198. </div>
  199. <div class="c-login-form__error">
  200. <#if messagesPerField.existsError('password-confirm')>
  201. ${kcSanitize(messagesPerField.get('password-confirm'))?no_esc}
  202. </#if>
  203. </div>
  204. </div>
  205. <input id="passwordNew" name="password-new" hidden >
  206. <input id="passwordConfirm" name="password-confirm" hidden >
  207. <button
  208. class="c-login-form__submit"
  209. name="login"
  210. onclick="onSubmit()"
  211. >
  212. 保存
  213. </button>
  214. </form>
  215. </div>
  216. <script src="${url.resourcesPath}/js/md5.js"></script>
  217. <script>
  218. function onSubmit () {
  219. var form = document.getElementById('loginForm')
  220. var value =document.getElementById('passwordNewProxy').value
  221. var res = checkPassword(value)
  222. if(res){
  223. window.alert(res)
  224. return
  225. }
  226. document.getElementById('passwordNew').value = MD5Salt(document.getElementById('passwordNewProxy').value)
  227. document.getElementById('passwordConfirm').value = MD5Salt(document.getElementById('passwordConfirmProxy').value)
  228. form.submit()
  229. }
  230. function checkPassword (password) {
  231. if (password.length < 8) {
  232. return '密码最少8位'
  233. }
  234. if (!/^[\da-zA-Z+_!@#$%^&*.,?]+$/.test(password)) {
  235. return '包含非法字符'
  236. }
  237. if (!/\d/.test(password)) {
  238. return '缺少数字'
  239. }
  240. if (!/[a-z]/.test(password)) {
  241. return '缺少小写字母'
  242. }
  243. if (!/[A-Z]/.test(password)) {
  244. return '缺少大写字母'
  245. }
  246. if (!/[+_!@#$%^&*.,?]/.test(password)) {
  247. return '缺少特殊字符'
  248. }
  249. return ''
  250. }
  251. </script>
  252. </body>
  253. </html>