Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts
- index 3cfdf2d..f4ca676 100644
- --- a/ui/src/app/app.component.ts
- +++ b/ui/src/app/app.component.ts
- @@ -55,11 +55,8 @@ import {EmployeeVariablesService} from './payrolls/prepare/employee-variables.se
- FiqlService,
- PayResultsService,
- EmployeeVariablesService,
- - AuthenticationService,
- - ApiService,
- UserService,
- - LocalizationService,
- - { provide: 'GP_API_HOST', useFactory: () => window.GPConfig.API_HOST },
- + LocalizationService
- ]
- })
- diff --git a/ui/src/app/app.module.ts b/ui/src/app/app.module.ts
- index 858b4be..241b61f 100644
- --- a/ui/src/app/app.module.ts
- +++ b/ui/src/app/app.module.ts
- @@ -68,7 +68,8 @@ import {ApiService} from './shared/api/api.service';
- PayrollsModule,
- EmployeesModule,
- AdministrationModule,
- - DashboardModule
- + DashboardModule,
- + BootstrapModalModule
- ],
- declarations: [
- AppComponent,
- @@ -89,9 +90,6 @@ import {ApiService} from './shared/api/api.service';
- bootstrap: [AppComponent],
- providers: [
- { provide: 'GP_API_HOST', useFactory: () => window.GPConfig.API_HOST },
- - BootstrapModalModule,
- - MomentModule,
- - ApiService
- ],
- entryComponents: []
- })
- diff --git a/ui/src/app/login/login.component.ts b/ui/src/app/login/login.component.ts
- index 6c7f60c..f0e9a43 100644
- --- a/ui/src/app/login/login.component.ts
- +++ b/ui/src/app/login/login.component.ts
- @@ -40,7 +40,7 @@ export class LoginComponent {
- login() {
- this.authenticationService.login(this.user.username, this.user.password).subscribe(user => {
- - this.router.navigate(['/dashboard']);
- + this.router.navigate(['dashboard']);
- }, error => {
- this.invalidCredentials = true;
- setTimeout(() => {
- diff --git a/ui/src/app/shared/authentication/authentication-guard.ts b/ui/src/app/shared/authentication/authentication-guard.ts
- index 0cc444a..044566a 100644
- --- a/ui/src/app/shared/authentication/authentication-guard.ts
- +++ b/ui/src/app/shared/authentication/authentication-guard.ts
- @@ -14,7 +14,7 @@
- */
- import {Injectable} from '@angular/core';
- -import {CanActivate} from '@angular/router';
- +import {CanActivate, Router} from '@angular/router';
- import {AuthenticationService} from './authentication.service.ts';
- import {LocalizationService} from '../localization';
- import {Observable} from 'rxjs';
- @@ -30,13 +30,15 @@ export class AuthenticationGuard implements CanActivate {
- publicRoutes: any;
- constructor(private l10n: LocalizationService,
- - private authenticationService: AuthenticationService) {
- + private authenticationService: AuthenticationService,
- + private router: Router) {
- }
- canActivate() {
- return this.authenticationService.isAuthenticated().then(authenticated => {
- if (!authenticated) {
- + this.router.navigate(['/login']);
- return false;
- }
- diff --git a/ui/src/app/shared/authentication/authentication.service.ts b/ui/src/app/shared/authentication/authentication.service.ts
- index 7e1a28d..5e8ca63 100644
- --- a/ui/src/app/shared/authentication/authentication.service.ts
- +++ b/ui/src/app/shared/authentication/authentication.service.ts
- @@ -15,6 +15,7 @@
- import {Injectable, EventEmitter, Inject} from '@angular/core';
- import {Http, Headers} from '@angular/http';
- import {Observable} from 'rxjs/Rx';
- +import {isPresent} from '../utils/lang';
- /**
- * Possible authentication events streamed by the authentication service
- @@ -49,7 +50,7 @@ export class AuthenticationService {
- if (this.userLoggedIn !== null) {
- return Promise.resolve(this.userLoggedIn);
- }
- - if (this.userLoggedInPromise === null) {
- + if (!isPresent(this.userLoggedInPromise)) {
- this.userLoggedInPromise = this.checkAuthentication();
- }
- return this.userLoggedInPromise;
- @@ -61,7 +62,8 @@ export class AuthenticationService {
- const headers = new Headers();
- headers.append('Authorization', `Bearer ${this.getToken()}`);
- // TODO: have a service just for verifying the token ?
- - return this.http.get(`${this.apiHost}/authent/api/v1/cliUser/me`, { headers }).toPromise().then(result => {
- + const promise = this.http.get(`${this.apiHost}/authent/api/v1/cliUser/me`, { headers }).toPromise()
- + return promise.then(result => {
- if (result.status === 200) {
- this.userLoggedIn = true;
- this.authenticationEvents.emit(AuthenticationEvent.TOKEN_VERIFIED);
- @@ -114,7 +116,6 @@ export class AuthenticationService {
- * of failed login
- */
- login(username: string, password: string, remember: Boolean = false): Observable<any> {
- -
- const headers = new Headers();
- headers.append('Content-Type', 'application/x-www-form-urlencoded');
- diff --git a/ui/src/app/shared/shared.module.ts b/ui/src/app/shared/shared.module.ts
- index b1c7d93..8c9aa1c 100644
- --- a/ui/src/app/shared/shared.module.ts
- +++ b/ui/src/app/shared/shared.module.ts
- @@ -27,6 +27,7 @@ import { ChartsModule } from './charts/charts.module';
- import { TablesModule } from './tables/tables.module';
- import { FilesModule } from './files/files.module';
- import { CanDeactivateGuard } from './routing/can-deactivate-guard';
- +import {ApiModule} from './api/api.module';
- @NgModule({
- imports: [
- @@ -40,7 +41,8 @@ import { CanDeactivateGuard } from './routing/can-deactivate-guard';
- UiModule,
- ChartsModule,
- TablesModule,
- - FilesModule
- + FilesModule,
- + ApiModule
- ],
- declarations: [],
- exports: [
- @@ -53,7 +55,8 @@ import { CanDeactivateGuard } from './routing/can-deactivate-guard';
- UiModule,
- ChartsModule,
- TablesModule,
- - FilesModule
- + FilesModule,
- + ApiModule
- ],
- providers: [CanDeactivateGuard]
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement