diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 80dcc1c4991170261a65bfa3ce0fd6f99b1e3fdd..1a09f92bcdb76ec9260abfe447fd3b079976e0c7 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -46,6 +46,7 @@ import { } from '@angular/material'; import { LoginScreenComponent } from './login-screen/login-screen.component'; import { NotificationService } from './notification.service'; +import { AuthenticationService } from './authentication.service'; @NgModule({ declarations: [ @@ -97,7 +98,10 @@ import { NotificationService } from './notification.service'; MatToolbarModule, MatTooltipModule ], - providers: [NotificationService], + providers: [ + NotificationService, + AuthenticationService + ], bootstrap: [AppComponent] }) export class AppModule { diff --git a/src/app/authentication.service.spec.ts b/src/app/authentication.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d04c8a68aa0cb0b714cc4abe5a6e2130ea9ccc4 --- /dev/null +++ b/src/app/authentication.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { AuthenticationService } from './authentication.service'; + +describe('AuthenticationService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [AuthenticationService] + }); + }); + + it('should be created', inject([AuthenticationService], (service: AuthenticationService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/src/app/authentication.service.ts b/src/app/authentication.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e43df89ea56a74471f68a05ab0e64483714e0c4 --- /dev/null +++ b/src/app/authentication.service.ts @@ -0,0 +1,37 @@ +import { Injectable } from '@angular/core'; +import { User } from './user'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; + +// TODO: connect to API +@Injectable() +export class AuthenticationService { + private mockUser: User = new User(1, 'test', 'test@test.de', true); + + constructor() { } + + login(email: string, password: string): Observable<boolean> { + return of(true); + } + + register(email: string, password: string): Observable<boolean> { + return of(true); + } + + resetPassword(email: string): Observable<boolean> { + return of(true); + } + + getUser(): Observable<User> { + return of(this.mockUser); + } + + isLoggedIn(): Observable<boolean> { + return of(this.mockUser !== null); + } + + isCreator(): Observable<boolean> { + return of(this.mockUser.isCreator); + } + +} diff --git a/src/app/user.ts b/src/app/user.ts index c63add3ba025e84d49a0ed446a637c37bf5da4a0..3283b2d7981295529a7e3d3c96058896fea06724 100644 --- a/src/app/user.ts +++ b/src/app/user.ts @@ -3,4 +3,11 @@ export class User { name: string; email: string; isCreator: boolean; + + constructor(id: number, name: string, email: string, isCreator: boolean) { + this.id = id; + this.name = name; + this.email = email; + this.isCreator = isCreator; + } }