Refactoring, adding some login logic stuff
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user