fix: auth guard
This commit is contained in:
@@ -46,7 +46,6 @@ export class ScreenLogin {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.api.checkAuthStatus().subscribe();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { Router } from '@angular/router';
|
|||||||
styleUrl: './screen-profile.less',
|
styleUrl: './screen-profile.less',
|
||||||
})
|
})
|
||||||
export class ScreenProfile implements OnInit{
|
export class ScreenProfile implements OnInit{
|
||||||
|
// TODO display real data
|
||||||
username = 'John Doe';
|
username = 'John Doe';
|
||||||
userID = 'testuser';
|
userID = 'testuser';
|
||||||
balance = 200;
|
balance = 200;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="Email or phone number"
|
placeholder="username"
|
||||||
[(ngModel)]="recipient"
|
[(ngModel)]="recipient"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,7 +16,12 @@ export class APIService {
|
|||||||
constructor(private http: HttpClient){}
|
constructor(private http: HttpClient){}
|
||||||
|
|
||||||
login(username: string, password: string): Observable<any>{
|
login(username: string, password: string): Observable<any>{
|
||||||
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<any>{
|
logout(): Observable<any>{
|
||||||
return this.http.post(`${this.apiUrl}/auth/logout`, {});
|
return this.http.post(`${this.apiUrl}/auth/logout`, {});
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ export const authGuard: CanActivateFn = (route, state) => {
|
|||||||
const api = inject(APIService);
|
const api = inject(APIService);
|
||||||
const router = inject(Router);
|
const router = inject(Router);
|
||||||
|
|
||||||
//FIXME always redirected to login after page load
|
return api.checkAuthStatus().pipe(
|
||||||
return api.isAuthenticated$.pipe(
|
|
||||||
map((isAuthenticated) => {
|
map((isAuthenticated) => {
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
14
server/src/messages/Transactions.ts
Normal file
14
server/src/messages/Transactions.ts
Normal file
@@ -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[],
|
||||||
|
){}
|
||||||
|
}
|
||||||
11
server/src/messages/User.ts
Normal file
11
server/src/messages/User.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import User from "../model/user";
|
||||||
|
|
||||||
|
export class UserRequest{
|
||||||
|
constructor(
|
||||||
|
){}
|
||||||
|
}
|
||||||
|
export class UserResponse{
|
||||||
|
constructor(
|
||||||
|
public user: User
|
||||||
|
){}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user