File tree Expand file tree Collapse file tree 4 files changed +26
-27
lines changed Expand file tree Collapse file tree 4 files changed +26
-27
lines changed Original file line number Diff line number Diff line change 142142 "account_modal" : {
143143 "title" : " Account" ,
144144 "logged_in_as" : " Logged in as {email}" ,
145- "logged_in_with_discord" : " Logged in with Discord"
145+ "logged_in_with_discord" : " Logged in with Discord" ,
146+ "recovery_email_sent" : " Recovery email sent to {email}"
146147 },
147148 "map" : {
148149 "map" : " Map" ,
Original file line number Diff line number Diff line change @@ -184,7 +184,11 @@ export class AccountModal extends LitElement {
184184 } ) ;
185185
186186 if ( response . ok ) {
187- alert ( `Recovery email sent to: ${ this . email } ` ) ;
187+ alert (
188+ translateText ( "account_modal.recovery_email_sent" , {
189+ email : this . email ,
190+ } ) ,
191+ ) ;
188192 this . close ( ) ;
189193 } else {
190194 console . error (
@@ -219,15 +223,10 @@ export class AccountModal extends LitElement {
219223 }
220224
221225 private async handleLogout ( ) {
222- try {
223- await logOut ( ) ;
224- this . close ( ) ;
225- // Refresh the page after logout to update the UI state
226- window . location . reload ( ) ;
227- } catch ( error ) {
228- console . error ( "Error during logout:" , error ) ;
229- alert ( "Error during logout. Please try again." ) ;
230- }
226+ await logOut ( ) ;
227+ this . close ( ) ;
228+ // Refresh the page after logout to update the UI state
229+ window . location . reload ( ) ;
231230 }
232231}
233232
Original file line number Diff line number Diff line change @@ -449,8 +449,8 @@ class Client {
449449 if ( token ) {
450450 strip ( ) ;
451451 window . addEventListener ( "beforeunload" , ( ) => {
452- // The page refreshes after token login, so we need to save the pattern name
453- // in case it is unset during login .
452+ // The page reloads after token login, so we need to save the pattern name
453+ // in case it is unset during reload .
454454 this . userSettings . setSelectedPatternName ( patternName ) ;
455455 } ) ;
456456 this . tokenLoginModal . open ( token ) ;
@@ -466,7 +466,7 @@ class Client {
466466
467467 if ( ! token ) {
468468 alertAndStrip (
469- `login failed! got url ${ window . location . href } Please try again.` ,
469+ `login failed! Please try again later or contact support .` ,
470470 ) ;
471471 return ;
472472 }
Original file line number Diff line number Diff line change @@ -75,22 +75,21 @@ export async function tokenLogin(token: string): Promise<string | null> {
7575 const response = await fetch (
7676 `${ getApiBase ( ) } /login/token?login-token=${ token } ` ,
7777 ) ;
78- if ( response . status === 200 ) {
79- const json = await response . json ( ) ;
80- const { jwt, email } = json ;
81- const payload = decodeJwt ( jwt ) ;
82- const result = TokenPayloadSchema . safeParse ( payload ) ;
83- if ( ! result . success ) {
84- console . error ( "Invalid token" , result . error , result . error . message ) ;
85- return null ;
86- }
87- clearToken ( ) ;
88- localStorage . setItem ( "token" , jwt ) ;
89- return email ;
90- } else {
78+ if ( response . status !== 200 ) {
9179 console . error ( "Token login failed" , response ) ;
9280 return null ;
9381 }
82+ const json = await response . json ( ) ;
83+ const { jwt, email } = json ;
84+ const payload = decodeJwt ( jwt ) ;
85+ const result = TokenPayloadSchema . safeParse ( payload ) ;
86+ if ( ! result . success ) {
87+ console . error ( "Invalid token" , result . error , result . error . message ) ;
88+ return null ;
89+ }
90+ clearToken ( ) ;
91+ localStorage . setItem ( "token" , jwt ) ;
92+ return email ;
9493}
9594
9695export function getAuthHeader ( ) : string {
You can’t perform that action at this time.
0 commit comments