Refactoring, adding some login logic stuff

This commit is contained in:
2022-09-03 13:01:54 +02:00
parent 47c494653c
commit 7b17b9b28a
13 changed files with 60 additions and 13 deletions
+22 -3
View File
@@ -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);
});
}
}