+
Not logged in
Please log in to continue
diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts
index 4b16191..e28272c 100644
--- a/src/app/components/profile/profile.component.ts
+++ b/src/app/components/profile/profile.component.ts
@@ -1,4 +1,5 @@
-import {Component, ElementRef, EventEmitter, HostListener, OnInit, Output} from '@angular/core';
+import {Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output} from '@angular/core';
+import {User} from '../../models/user';
@Component({
selector: 'app-profile',
@@ -8,6 +9,7 @@ import {Component, ElementRef, EventEmitter, HostListener, OnInit, Output} from
export class ProfileComponent implements OnInit {
initialClick = true;
+ @Input() user?: User;
@Output() showProfilePopoverChange = new EventEmitter
();
isLoggedIn = true;
diff --git a/src/app/models/enums/announcement.ts b/src/app/models/doppelkopf/enums/announcement.ts
similarity index 100%
rename from src/app/models/enums/announcement.ts
rename to src/app/models/doppelkopf/enums/announcement.ts
diff --git a/src/app/models/enums/solo.ts b/src/app/models/doppelkopf/enums/solo.ts
similarity index 100%
rename from src/app/models/enums/solo.ts
rename to src/app/models/doppelkopf/enums/solo.ts
diff --git a/src/app/models/enums/team.ts b/src/app/models/doppelkopf/enums/team.ts
similarity index 100%
rename from src/app/models/enums/team.ts
rename to src/app/models/doppelkopf/enums/team.ts
diff --git a/src/app/models/game.ts b/src/app/models/doppelkopf/game.ts
similarity index 100%
rename from src/app/models/game.ts
rename to src/app/models/doppelkopf/game.ts
diff --git a/src/app/models/player.ts b/src/app/models/doppelkopf/player.ts
similarity index 100%
rename from src/app/models/player.ts
rename to src/app/models/doppelkopf/player.ts
diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts
index 411e2d7..be7252e 100644
--- a/src/app/pages/home/home.component.ts
+++ b/src/app/pages/home/home.component.ts
@@ -1,5 +1,8 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
+import {User} from '../../models/user';
+import {ApiService} from '../../services/api.service';
+import {StorageService} from '../../services/storage.service';
@Component({
selector: 'app-home',
@@ -14,9 +17,25 @@ export class HomeComponent implements OnInit {
}
ngOnInit(): void {
- this.route.queryParams.subscribe(params => {
- // Read params
- });
+ this.authenticateUser();
}
+ /**
+ * Reads authentication details from query parameters and tries to authenticate the user with the API.
+ * @private
+ */
+ private authenticateUser() {
+ this.route.queryParams.subscribe(params => {
+ let user: User = {
+ firebonkId: params['firebonkId'],
+ uuid: '',
+ firstName: params['firstName'],
+ token: params['token'],
+ sessionKey: ''
+ };
+
+ let authenticatedUser = ApiService.performAuthentication(user);
+ StorageService.setUserInfo(authenticatedUser);
+ });
+ }
}
diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts
new file mode 100644
index 0000000..57230c3
--- /dev/null
+++ b/src/app/services/api.service.ts
@@ -0,0 +1,13 @@
+import {User} from '../models/user';
+
+export class ApiService {
+ static apiUrl = 'https://api.plutodev.de/fbcards/';
+
+ /**
+ * Sends user info to API to retrieve a session key.
+ * @param user
+ */
+ static performAuthentication(user: User): User {
+ return user;
+ }
+}
diff --git a/src/app/services/storage.service.ts b/src/app/services/storage.service.ts
index 32b504c..f7b5aae 100644
--- a/src/app/services/storage.service.ts
+++ b/src/app/services/storage.service.ts
@@ -1,7 +1,11 @@
import {User} from '../models/user';
export class StorageService {
- getUserInfo(): User {
+ static getUserInfo(): User | undefined {
+ if(localStorage.getItem('user_loggedIn') !== '1') {
+ return undefined;
+ }
+
const firebonkId = parseInt((localStorage.getItem('user_firebonkId') ?? '-1'), 10);
const uuid = localStorage.getItem('user_uuid') ?? '';
const firstName = localStorage.getItem('user_firstName') ?? '';
@@ -17,7 +21,8 @@ export class StorageService {
};
}
- setUserInfo(user: User): void {
+ static setUserInfo(user: User): void {
+ localStorage.setItem('user_loggedIn', '1');
localStorage.setItem('user_firebonkId', String(user.firebonkId));
localStorage.setItem('user_uuid', String(user.uuid));
localStorage.setItem('user_firstName', String(user.firstName));