Skip to content

Commit

Permalink
[#6] create identity api service
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphoeninger committed Oct 22, 2024
1 parent e1b0175 commit 3611284
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CLIENT/CLIENT.FileSharing/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { NavbarComponent } from './navigation/navbar/navbar.component';
import { ToolbarComponent } from './navigation/toolbar/toolbar.component';
import { LoginComponent } from './identity/login/login.component';

@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, NavbarComponent, ToolbarComponent],
imports: [RouterOutlet, NavbarComponent, ToolbarComponent, LoginComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
Expand Down
13 changes: 11 additions & 2 deletions CLIENT/CLIENT.FileSharing/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideHttpClient, withFetch } from '@angular/common/http';
import {
provideHttpClient,
withFetch,
withInterceptors,
} from '@angular/common/http';
import { authInterceptor } from './identity/shared/auth.interceptor';

export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideAnimationsAsync(),
provideHttpClient(withFetch()),
provideHttpClient(withFetch(), withInterceptors([authInterceptor])),
],
};

export const httpAppConfig: any = {
apiEndpoint: 'https://localhost:5001/api',
};
7 changes: 6 additions & 1 deletion CLIENT/CLIENT.FileSharing/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { SharedComponent } from './pages/shared-component/shared.component';
import { UploadsComponent } from './pages/uploads/uploads.component';
import { ProfileComponent } from './pages/profile/profile.component';
import { SettingsComponent } from './pages/settings/settings.component';
import { LoginComponent } from './identity/login/login.component';

export const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'home',
redirectTo: 'auth',
},
{
path: 'auth',
component: LoginComponent,
},
{
path: 'home',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { httpAppConfig } from '../../app.config';
import { Observable, of as observableOf } from 'rxjs';
import { LoginModel } from './login.model';

@Injectable({ providedIn: 'root' })
export class IdentityApiService {
constructor(private http: HttpClient) {}

login(command: LoginModel): Observable<any> {
return this.http.post<any>(`${httpAppConfig.apiEndpoint}/signIn`, command, {
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
});
}
}

0 comments on commit 3611284

Please sign in to comment.