@@ -176,35 +176,30 @@ class Authentication {
176176 }
177177 } ) ;
178178 }
179- static usernameFromCode ( username , token , clear_cache = false ) {
179+ static async usernameFromCode ( _username , token ) {
180180 // name is a misnomer, was just to lazy to change after new api update.
181181 // TODO: make this less misleading
182- return new Promise ( ( resolve , reject ) => {
183- const cc = clear_cache
184- ? {
185- cache : "reload" ,
186- }
187- : { } ;
188- fetch (
189- `${ ProjectApi . OriginApiUrl } /api/v1/users/userfromcode?username=${ username } &token=${ token } ` ,
190- cc ,
191- )
192- . then ( ( r ) =>
193- r
194- . json ( )
195- . then ( ( j ) => {
196- if ( j . error ) return reject ( j . error ) ;
197- resolve ( {
198- username : j . username ,
199- isAdmin : j . admin ,
200- isApprover : j . approver ,
201- ...j ,
202- } ) ;
203- } )
204- . catch ( reject ) ,
205- )
206- . catch ( reject ) ;
207- } ) ;
182+ const j = await fetch (
183+ `${ ProjectApi . OriginApiUrl } /api/v1/users/userfromcode?token=${ token } ` ,
184+ ) . then ( ( r ) => r . json ( ) ) ;
185+
186+ if ( j . error ) throw j . error ;
187+
188+ if ( ! j . birthdayEntered || ! j . countryEntered || ! j . isEmailVerified ) {
189+ const extra = await fetch (
190+ `${ ProjectApi . OriginApiUrl } /api/v1/users/extrainfostatus?token=${ token } ` ,
191+ ) . then ( ( r ) => r . json ( ) ) ;
192+
193+ j . birthdayEntered = extra . birthdayEntered ;
194+ j . countryEntered = extra . countryEntered ;
195+ j . isEmailVerified = extra . isEmailVerified ;
196+ }
197+
198+ return {
199+ isAdmin : j . admin ,
200+ isApprover : j . approver ,
201+ ...j ,
202+ } ;
208203 }
209204
210205 static changePassword ( username , token , oldPassword , newPassword ) {
0 commit comments