fixed auth module

This commit is contained in:
Giuseppe Digilio
2018-02-10 13:01:58 +01:00
parent 64ad40b676
commit b7cff01dab
14 changed files with 147 additions and 109 deletions

View File

@@ -17,6 +17,9 @@ import { MetadataService } from './core/metadata/metadata.service';
import { HostWindowResizeAction } from './shared/host-window.actions';
import { HostWindowState } from './shared/host-window.reducer';
import { NativeWindowRef, NativeWindowService } from './shared/services/window.service';
import { CheckAuthenticationTokenAction } from './core/auth/auth.actions';
import { isAuthenticated } from './core/auth/selectors';
import { PlatformService } from './shared/services/platform.service';
@Component({
selector: 'ds-app',
@@ -32,7 +35,8 @@ export class AppComponent implements OnInit {
@Inject(NativeWindowService) private _window: NativeWindowRef,
private translate: TranslateService,
private store: Store<HostWindowState>,
private metadata: MetadataService
private metadata: MetadataService,
private platformService: PlatformService
) {
// this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en');
@@ -51,6 +55,12 @@ export class AppComponent implements OnInit {
const color: string = this.config.production ? 'red' : 'green';
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
this.dispatchWindowSize(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight);
if (this.platformService.isServer) {
this.store.select(isAuthenticated)
.take(1)
.filter((authenticated) => !authenticated)
.subscribe((authenticated) => this.store.dispatch(new CheckAuthenticationTokenAction()));
}
}
@HostListener('window:resize', ['$event'])