File tree Expand file tree Collapse file tree
application/src/main/resources/templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44</ th:block >
55
66< th:block th:fragment ="basicScriptResources ">
7+ < th:block th:if ="${not #strings.isEmpty(publicKey)} and ${fragmentTemplateName} == 'login_local' ">
8+ < script src ="/webjars/jsencrypt/3.5.4/bin/jsencrypt.min.js " defer > </ script >
9+ < script th:inline ="javascript " type ="text/javascript ">
10+ const publicKey = /*[[${publicKey}]]*/ "" ;
11+
12+ // Encrypt function
13+ function encryptPassword ( password ) {
14+ const encrypt = new JSEncrypt ( ) ;
15+ encrypt . setPublicKey ( publicKey ) ;
16+ return encrypt . encrypt ( password ) ;
17+ }
18+
19+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
20+ const loginForm = document . getElementById ( "login-form" ) ;
21+ loginForm . addEventListener ( "submit" , function ( event ) {
22+ const plainPasswordInput = document . getElementById ( "plainPassword" ) ;
23+ const passwordInput = document . getElementById ( "password" ) ;
24+ passwordInput . value = encryptPassword ( plainPasswordInput . value ) ;
25+ } ) ;
26+ } ) ;
27+ </ script >
28+ </ th:block >
29+
730 < script th:inline ="javascript ">
831 const i18nResources = {
932 sendVerificationCodeSuccess : `[(#{js.sendVerificationCode.success})]` ,
Original file line number Diff line number Diff line change 11< div th:remove ="tag " th:fragment ="form ">
2- < script src ="/webjars/jsencrypt/3.5.4/bin/jsencrypt.min.js " defer > </ script >
3- < script th:inline ="javascript " type ="text/javascript ">
4- const publicKey = /*[[${publicKey}]]*/ "" ;
5-
6- // Encrypt function
7- function encryptPassword ( password ) {
8- const encrypt = new JSEncrypt ( ) ;
9- encrypt . setPublicKey ( publicKey ) ;
10- return encrypt . encrypt ( password ) ;
11- }
12-
13- document . addEventListener ( "DOMContentLoaded" , function ( ) {
14- const loginForm = document . getElementById ( "login-form" ) ;
15- loginForm . addEventListener ( "submit" , function ( event ) {
16- const plainPasswordInput = document . getElementById ( "plainPassword" ) ;
17- const passwordInput = document . getElementById ( "password" ) ;
18- passwordInput . value = encryptPassword ( plainPasswordInput . value ) ;
19- } ) ;
20- } ) ;
21- </ script >
22-
232 < input type ="hidden " name ="password " id ="password " />
243
254 < div class ="form-item ">
You can’t perform that action at this time.
0 commit comments