diff --git a/project-manager/projects-server/db.json b/project-manager/projects-server/db.json index 51912a3..ed5badd 100644 --- a/project-manager/projects-server/db.json +++ b/project-manager/projects-server/db.json @@ -17,10 +17,10 @@ "description": "Nicht länger als 15 Minuten... ", "tags": [], "assignee": { - "name": "John Doe", - "email": "john@doe.com" + "name": "", + "email": "" }, - "state": "BACKLOG" + "state": "IN_PROGRESS" }, { "title": "Test der Websocket-Funktionalität", @@ -54,4 +54,4 @@ "change_settings": false } ] -} +} \ No newline at end of file diff --git a/project-manager/src/app/login/login.component.ts b/project-manager/src/app/login/login.component.ts index 6714344..030ad47 100644 --- a/project-manager/src/app/login/login.component.ts +++ b/project-manager/src/app/login/login.component.ts @@ -18,8 +18,7 @@ export class LoginComponent { } login(userName: string, password: string) { - const result = this.loginService.login(userName, password); - if (result) { + if (this.loginService.login(userName, password)) { const queryParams = this.route.snapshot.queryParams; const redirect = queryParams['redirect'] || '/'; this.router.navigateByUrl(decodeURI(redirect)); diff --git a/project-manager/src/app/services/login-service/login-service.ts b/project-manager/src/app/services/login-service/login-service.ts index 0cacfe0..378d60d 100644 --- a/project-manager/src/app/services/login-service/login-service.ts +++ b/project-manager/src/app/services/login-service/login-service.ts @@ -19,27 +19,28 @@ export class LoginService { users$: Observable; + results$: User[]; + constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled = false, private http: Http, private userStore: UserStore, @Inject(SOCKET_IO) socketIO) { this.users$ = userStore.items$; this.socket = socketIO(WEB_SOCKET_URL); } - getUser(name: string): User[] { - let results; - this.http.get(BASE_URL + "?name=" + name).subscribe(result => results = result.json()); - return results; + getUser(name: string) { + this.http.get(BASE_URL + "?name=" + name).subscribe(result => this.results$ = result.json()); + return this.results$; } - login(name, password) { - let results = this.getUser(name); - if (results) { - let user = results[0]; + login(name, password) : boolean { + if (this.getUser(name)) { + let user = this.results$[0]; let passMd5 = Md5.hashStr(password); if (user && user.password === passMd5) { localStorage.setItem(CURRENT_USER, JSON.stringify(user)); return true; } + return false; } } diff --git a/project-manager/src/app/services/login-service/login.service.spec.ts b/project-manager/src/app/services/login-service/login.service.spec.ts index d01cc64..c82ac2b 100644 --- a/project-manager/src/app/services/login-service/login.service.spec.ts +++ b/project-manager/src/app/services/login-service/login.service.spec.ts @@ -39,7 +39,6 @@ describe('Login-Service', () => { ); it('should trigger a HTTP-GET and receive Task', (() => { - console.log(userStore.items$); mockBackend.connections.subscribe(connection => { const expectedUrl = 'http://localhost:3000/api/users/'; expect(connection.request.url).toBe(expectedUrl); diff --git a/project-manager/src/app/services/stores/task.store.ts b/project-manager/src/app/services/stores/task.store.ts index 7eff8dd..24a57fc 100644 --- a/project-manager/src/app/services/stores/task.store.ts +++ b/project-manager/src/app/services/stores/task.store.ts @@ -11,7 +11,6 @@ export class TaskStore { items$ = new BehaviorSubject([]); dispatch(action) { - console.log("dispatched") this.tasks = this._reduce(this.tasks, action); this.items$.next(this.tasks); } diff --git a/project-manager/src/app/services/stores/user.store.ts b/project-manager/src/app/services/stores/user.store.ts index dea3677..cb8edce 100644 --- a/project-manager/src/app/services/stores/user.store.ts +++ b/project-manager/src/app/services/stores/user.store.ts @@ -9,7 +9,6 @@ export class UserStore { items$ = new BehaviorSubject([]); dispatch(action) { - console.log("dispatched") this.users = this._reduce(this.users, action); this.items$.next(this.users); }