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 () {
15
15
16
16
axios . interceptors . response . use (
17
17
response => {
18
- let statusCode = response . status ;
19
18
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 ;
20
30
if ( statusCode == 200 && offlineMode ) {
21
31
showLostConnectionPopup ( false ) ;
22
32
}
@@ -70,6 +80,8 @@ function logout() {
70
80
71
81
function destroySession ( ) {
72
82
localStorage . removeItem ( "token" ) ;
83
+ localStorage . removeItem ( "token_expires_at" ) ;
84
+ localStorage . removeItem ( "username" ) ;
73
85
//the code below would remove user preferences (if that is ever added)
74
86
//localStorage.clear();
75
87
}
Original file line number Diff line number Diff line change @@ -68,8 +68,13 @@ function login() {
68
68
69
69
JSON . stringify ( result )
70
70
let token = result [ "access_token" ]
71
+ let expirationDate = result [ "expires_at" ]
72
+ let username = result [ "userName" ]
71
73
72
74
localStorage . setItem ( "token" , token )
75
+ localStorage . setItem ( "token_expires_at" , expirationDate )
76
+ localStorage . setItem ( "username" , username )
77
+
73
78
window . location . href = "/panel.html" ;
74
79
} )
75
80
return ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ <h1>MCSS Remote Login</h1>
56
56
< div class ="content ">
57
57
< div class ="description ">
58
58
< 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 >
60
60
</ div >
61
61
62
62
< 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