Skip to content

Commit

Permalink
Logout on auth/me error
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-hasani committed Sep 4, 2023
1 parent e4ec164 commit 51586e0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
13 changes: 0 additions & 13 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,6 @@
"outputHashing": "all"
},
"development": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "10kb",
"maximumError": "20kb"
}
],
"outputHashing": "all",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
Expand Down
17 changes: 10 additions & 7 deletions src/app/modules/core/services/initialization.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Injectable } from '@angular/core';
import { CoreFacade } from '../+state/core.facade';
import { UserWithTokenResponse } from '../../auth/data-access/dto/auth.dto';
import { AuthService } from '../../auth/data-access/services/auth.service';
import { CoreAuthApiService } from '../apis/core-auth.api.service';
import { StorageService } from './storage.service';
@Injectable()
export class InitializationService {
constructor(
private authAPI: CoreAuthApiService,
private coreFacade: CoreFacade,
private storage: StorageService
private storage: StorageService,
private authService: AuthService
) {}

async initializeApp(): Promise<void> {
Expand All @@ -26,11 +28,12 @@ export class InitializationService {
}

async getUserWithAccessToken(): Promise<void> {
const result: UserWithTokenResponse = await this.authAPI
.meSync()
.catch((error) => {
throw error;
});
this.coreFacade.setUser(result.user);
try {
const result: UserWithTokenResponse = await this.authAPI.meSync();
this.coreFacade.setUser(result.user);
} catch (error) {
console.error('Error on auth/me', error);
this.authService.logout();
}
}
}
4 changes: 0 additions & 4 deletions src/app/shared/interfaces/environment.interface.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/shared/interfaces/index.ts

This file was deleted.

0 comments on commit 51586e0

Please sign in to comment.