diff --git a/client/src/app/screens/screen-login/screen-login.ts b/client/src/app/screens/screen-login/screen-login.ts index 79efd5a..5d408b5 100644 --- a/client/src/app/screens/screen-login/screen-login.ts +++ b/client/src/app/screens/screen-login/screen-login.ts @@ -46,7 +46,6 @@ export class ScreenLogin { this.loading = false; } }); - this.api.checkAuthStatus().subscribe(); } } diff --git a/client/src/app/screens/screen-profile/screen-profile.ts b/client/src/app/screens/screen-profile/screen-profile.ts index 6f44ce0..f4db7e9 100644 --- a/client/src/app/screens/screen-profile/screen-profile.ts +++ b/client/src/app/screens/screen-profile/screen-profile.ts @@ -11,6 +11,7 @@ import { Router } from '@angular/router'; styleUrl: './screen-profile.less', }) export class ScreenProfile implements OnInit{ + // TODO display real data username = 'John Doe'; userID = 'testuser'; balance = 200; diff --git a/client/src/app/screens/screen-send/screen-send.html b/client/src/app/screens/screen-send/screen-send.html index dde6126..f13095e 100644 --- a/client/src/app/screens/screen-send/screen-send.html +++ b/client/src/app/screens/screen-send/screen-send.html @@ -28,7 +28,7 @@ diff --git a/client/src/app/services/api.ts b/client/src/app/services/api.ts index 27ea0df..eb80c66 100644 --- a/client/src/app/services/api.ts +++ b/client/src/app/services/api.ts @@ -16,7 +16,12 @@ export class APIService { constructor(private http: HttpClient){} login(username: string, password: string): Observable{ - return this.http.post(`${this.apiUrl}/auth/login`,{ 'username': username, 'password': password}); + return this.http.post(`${this.apiUrl}/auth/login`,{ 'username': username, 'password': password}).pipe( + tap({ + next: () => this.isAuthenticatedSubject.next(true), + error: () => this.isAuthenticatedSubject.next(false) + }) + ); } logout(): Observable{ return this.http.post(`${this.apiUrl}/auth/logout`, {}); diff --git a/client/src/app/services/auth-guard.ts b/client/src/app/services/auth-guard.ts index e136b7d..220659f 100644 --- a/client/src/app/services/auth-guard.ts +++ b/client/src/app/services/auth-guard.ts @@ -7,8 +7,7 @@ export const authGuard: CanActivateFn = (route, state) => { const api = inject(APIService); const router = inject(Router); - //FIXME always redirected to login after page load - return api.isAuthenticated$.pipe( + return api.checkAuthStatus().pipe( map((isAuthenticated) => { if (isAuthenticated) { return true; diff --git a/server/src/messages/Transactions.ts b/server/src/messages/Transactions.ts new file mode 100644 index 0000000..bebde2d --- /dev/null +++ b/server/src/messages/Transactions.ts @@ -0,0 +1,14 @@ +import Transaction from "../model/transaction"; + +export class TransactionsRequest{ + constructor( + public offset = 0, + public count = 50, + ){} +} + +export class TransactionsResponse{ + constructor( + public transactions: Transaction[], + ){} +} \ No newline at end of file diff --git a/server/src/messages/User.ts b/server/src/messages/User.ts new file mode 100644 index 0000000..057678d --- /dev/null +++ b/server/src/messages/User.ts @@ -0,0 +1,11 @@ +import User from "../model/user"; + +export class UserRequest{ + constructor( + ){} +} +export class UserResponse{ + constructor( + public user: User + ){} +} \ No newline at end of file