@@ -15,7 +15,7 @@ export class CurrentUser {
15
15
@observable
16
16
public loggedIn = false ;
17
17
@observable
18
- public authenticating = false ;
18
+ public authenticating = true ;
19
19
@observable
20
20
public user : IUser = { name : 'unknown' , admin : false , id : - 1 } ;
21
21
@observable
@@ -80,17 +80,11 @@ export class CurrentUser {
80
80
. then ( ( resp : AxiosResponse < IClient > ) => {
81
81
this . snack ( `A client named '${ name } ' was created for your session.` ) ;
82
82
this . setToken ( resp . data . token ) ;
83
- this . tryAuthenticate ( )
84
- . then ( ( ) => {
85
- this . authenticating = false ;
86
- this . loggedIn = true ;
87
- } )
88
- . catch ( ( ) => {
89
- this . authenticating = false ;
90
- console . log (
91
- 'create client succeeded, but authenticated with given token failed'
92
- ) ;
93
- } ) ;
83
+ this . tryAuthenticate ( ) . catch ( ( ) => {
84
+ console . log (
85
+ 'create client succeeded, but authenticated with given token failed'
86
+ ) ;
87
+ } ) ;
94
88
} )
95
89
. catch ( ( ) => {
96
90
this . authenticating = false ;
@@ -100,6 +94,7 @@ export class CurrentUser {
100
94
101
95
public tryAuthenticate = async ( ) : Promise < AxiosResponse < IUser > > => {
102
96
if ( this . token ( ) === '' ) {
97
+ this . authenticating = false ;
103
98
return Promise . reject ( ) ;
104
99
}
105
100
@@ -111,11 +106,13 @@ export class CurrentUser {
111
106
. then ( ( passThrough ) => {
112
107
this . user = passThrough . data ;
113
108
this . loggedIn = true ;
109
+ this . authenticating = false ;
114
110
this . connectionErrorMessage = null ;
115
111
this . reconnectTime = 7500 ;
116
112
return passThrough ;
117
113
} )
118
114
. catch ( ( error : AxiosError ) => {
115
+ this . authenticating = false ;
119
116
if ( ! error || ! error . response ) {
120
117
this . connectionError ( 'No network connection or server unavailable.' ) ;
121
118
return Promise . reject ( error ) ;
0 commit comments