@ -28,6 +28,7 @@ export default {
connectCount : 0 ,
connectCount : 0 ,
initedSocketIO : false ,
initedSocketIO : false ,
} ,
} ,
username : null ,
remember : ( localStorage . remember !== "0" ) ,
remember : ( localStorage . remember !== "0" ) ,
allowLoginDialog : false , // Allowed to show login dialog, but "loggedIn" have to be true too. This exists because prevent the login dialog show 0.1s in first before the socket server auth-ed.
allowLoginDialog : false , // Allowed to show login dialog, but "loggedIn" have to be true too. This exists because prevent the login dialog show 0.1s in first before the socket server auth-ed.
loggedIn : false ,
loggedIn : false ,
@ -102,6 +103,7 @@ export default {
socket . on ( "autoLogin" , ( monitorID , data ) => {
socket . on ( "autoLogin" , ( monitorID , data ) => {
this . loggedIn = true ;
this . loggedIn = true ;
this . username = "No Auth" ;
this . storage ( ) . token = "autoLogin" ;
this . storage ( ) . token = "autoLogin" ;
this . allowLoginDialog = false ;
this . allowLoginDialog = false ;
} ) ;
} ) ;
@ -233,7 +235,6 @@ export default {
if ( token !== "autoLogin" ) {
if ( token !== "autoLogin" ) {
this . loginByToken ( token ) ;
this . loginByToken ( token ) ;
} else {
} else {
// Timeout if it is not actually auto login
// Timeout if it is not actually auto login
setTimeout ( ( ) => {
setTimeout ( ( ) => {
if ( ! this . loggedIn ) {
if ( ! this . loggedIn ) {
@ -241,7 +242,6 @@ export default {
this . $root . storage ( ) . removeItem ( "token" ) ;
this . $root . storage ( ) . removeItem ( "token" ) ;
}
}
} , 5000 ) ;
} , 5000 ) ;
}
}
} else {
} else {
this . allowLoginDialog = true ;
this . allowLoginDialog = true ;
@ -305,6 +305,7 @@ export default {
this . storage ( ) . token = res . token ;
this . storage ( ) . token = res . token ;
this . socket . token = res . token ;
this . socket . token = res . token ;
this . loggedIn = true ;
this . loggedIn = true ;
this . username = this . getJWTPayload ( ) ? . username ;
// Trigger Chrome Save Password
// Trigger Chrome Save Password
history . pushState ( { } , "" ) ;
history . pushState ( { } , "" ) ;
@ -322,6 +323,7 @@ export default {
this . logout ( ) ;
this . logout ( ) ;
} else {
} else {
this . loggedIn = true ;
this . loggedIn = true ;
this . username = this . getJWTPayload ( ) ? . username ;
}
}
} ) ;
} ) ;
} ,
} ,
@ -331,6 +333,7 @@ export default {
this . storage ( ) . removeItem ( "token" ) ;
this . storage ( ) . removeItem ( "token" ) ;
this . socket . token = null ;
this . socket . token = null ;
this . loggedIn = false ;
this . loggedIn = false ;
this . username = null ;
this . clearData ( ) ;
this . clearData ( ) ;
} ,
} ,
@ -398,6 +401,14 @@ export default {
computed : {
computed : {
usernameFirstChar ( ) {
if ( typeof this . username == "string" && this . username . length >= 1 ) {
return this . username . charAt ( 0 ) . toUpperCase ( ) ;
} else {
return "🐻" ;
}
} ,
lastHeartbeatList ( ) {
lastHeartbeatList ( ) {
let result = { } ;
let result = { } ;