File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,18 @@ document.addEventListener("DOMContentLoaded", function () {
1515
1616 axios . interceptors . response . use (
1717 response => {
18- let statusCode = response . status ;
1918
19+ if ( localStorage . getItem ( "token_expires_at" ) != null ) {
20+ let currentDate = Math . floor ( Date . now ( ) / 1000 ) ;
21+ let expirationDate = localStorage . getItem ( "token_expires_at" ) ;
22+
23+ if ( expirationDate < currentDate ) {
24+ console . log ( "Your session has timed out." )
25+ logout ( ) ;
26+ }
27+ }
28+
29+ let statusCode = response . status ;
2030 if ( statusCode == 200 && offlineMode ) {
2131 showLostConnectionPopup ( false ) ;
2232 }
@@ -70,6 +80,8 @@ function logout() {
7080
7181function destroySession ( ) {
7282 localStorage . removeItem ( "token" ) ;
83+ localStorage . removeItem ( "token_expires_at" ) ;
84+ localStorage . removeItem ( "username" ) ;
7385 //the code below would remove user preferences (if that is ever added)
7486 //localStorage.clear();
7587}
Original file line number Diff line number Diff line change @@ -68,8 +68,13 @@ function login() {
6868
6969 JSON . stringify ( result )
7070 let token = result [ "access_token" ]
71+ let expirationDate = result [ "expires_at" ]
72+ let username = result [ "userName" ]
7173
7274 localStorage . setItem ( "token" , token )
75+ localStorage . setItem ( "token_expires_at" , expirationDate )
76+ localStorage . setItem ( "username" , username )
77+
7378 window . location . href = "/panel.html" ;
7479 } )
7580 return ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ <h1>MCSS Remote Login</h1>
5656 < div class ="content ">
5757 < div class ="description ">
5858 < div class ="ui header ">
59- < p > MCSS Remote Panel v3.0.0 < a href ="https://github.com/mcserversoft/RemotePanel " target ="_blank "> < i class ="github icon "> </ i > </ a > </ p >
59+ < p > MCSS Remote Panel v3.0.1 < a href ="https://github.com/mcserversoft/RemotePanel " target ="_blank "> < i class ="github icon "> </ i > </ a > </ p >
6060 </ div >
6161
6262 < p > Created by < a href ="https://github.com/stefmmm " target ="_blank "> Stefmmm</ a > and < a href ="https://github.com/mcserversoft/RemotePanel/graphs/contributors " target ="_blank "> contributors</ a > .</ p >
You can’t perform that action at this time.
0 commit comments