File tree 2 files changed +26
-21
lines changed
2 files changed +26
-21
lines changed Original file line number Diff line number Diff line change 7
7
</ head >
8
8
9
9
< body >
10
- < div class ="login ">
11
- < div class ="back "> < - Back </ div >
12
- < h4 class ="title "> code-server</ h4 >
13
- < h2 class ="subtitle ">
14
- Enter server password
15
- </ h2 >
16
- < div class ="mdc-text-field ">
17
- < input type ="password " id ="password " class ="mdc-text-field__input " required >
18
- < label class ="mdc-floating-label " for ="password "> Password</ label >
19
- < div class ="mdc-line-ripple "> </ div >
20
- </ div >
21
- < button id ="submit " class ="mdc-button mdc-button--unelevated ">
22
- < span class ="mdc-button__label "> Enter IDE</ span >
23
- </ button >
24
- < div id ="error-display "> </ div >
25
- </ div >
10
+ < form id ="login-form ">
11
+ < div class ="login ">
12
+ < div class ="back ">
13
+ < - Back </ div > < h4 class ="title "> code-server</ h4 >
14
+ < h2 class ="subtitle ">
15
+ Enter server password
16
+ </ h2 >
17
+ < div class ="mdc-text-field ">
18
+ < input type ="password " id ="password " class ="mdc-text-field__input " required >
19
+ < label class ="mdc-floating-label " for ="password "> Password</ label >
20
+ < div class ="mdc-line-ripple "> </ div >
21
+ </ div >
22
+ < button id ="submit " class ="mdc-button mdc-button--unelevated ">
23
+ < span class ="mdc-button__label "> Enter IDE</ span >
24
+ </ button >
25
+ < div id ="error-display "> </ div >
26
+ </ div >
27
+ </ form >
26
28
</ body >
27
29
28
30
</ html >
Original file line number Diff line number Diff line change @@ -20,11 +20,14 @@ window.addEventListener("message", (event) => {
20
20
} ) ;
21
21
22
22
const password = document . getElementById ( "password" ) as HTMLInputElement ;
23
- const submit = document . getElementById ( "submit" ) as HTMLButtonElement ;
24
- if ( ! submit ) {
25
- throw new Error ( "No submit button found" ) ;
23
+ const form = document . getElementById ( "login-form" ) as HTMLFormElement ;
24
+
25
+ if ( ! form ) {
26
+ throw new Error ( "No password form found" ) ;
26
27
}
27
- submit . addEventListener ( "click" , ( ) => {
28
+
29
+ form . addEventListener ( "submit" , ( e ) => {
30
+ e . preventDefault ( ) ;
28
31
document . cookie = `password=${ password . value } ` ;
29
32
location . reload ( ) ;
30
33
} ) ;
@@ -38,4 +41,4 @@ const errorDisplay = document.getElementById("error-display") as HTMLDivElement;
38
41
39
42
if ( document . referrer === document . location . href && matches ) {
40
43
errorDisplay . innerText = "Password is incorrect!" ;
41
- }
44
+ }
You can’t perform that action at this time.
0 commit comments