Browse Source

Refactorings.

pull/65/merge
Sebastian Stehle 9 years ago
parent
commit
68f5575a38
  1. 6
      src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts
  2. 4
      src/Squidex/app/shared/guards/must-be-authenticated.guard.ts
  3. 4
      src/Squidex/app/shared/guards/must-be-not-authenticated.guard.ts
  4. 8
      src/Squidex/app/shared/services/apps-store.service.ts
  5. 6
      src/Squidex/app/shell/pages/home/home-page.component.ts
  6. 8
      src/Squidex/app/shell/pages/internal/profile-menu.component.ts
  7. 4
      src/Squidex/app/shell/pages/login/login-page.component.ts
  8. 4
      src/Squidex/app/shell/pages/logout/logout-page.component.ts

6
src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts

@ -65,7 +65,7 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit,
public callsMax: string | null = null;
constructor(apps: AppsStoreService, notifications: NotificationService,
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly usagesService: UsagesService
) {
super(notifications, apps);
@ -155,8 +155,8 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit,
});
this.authenticationSubscription =
this.auth.isAuthenticated.subscribe(() => {
const user = this.auth.user;
this.authService.isAuthenticated.subscribe(() => {
const user = this.authService.user;
if (user) {
this.profileDisplayName = user.displayName;

4
src/Squidex/app/shared/guards/must-be-authenticated.guard.ts

@ -13,13 +13,13 @@ import { AuthService } from './../services/auth.service';
@Injectable()
export class MustBeAuthenticatedGuard implements CanActivate {
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly router: Router
) {
}
public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
return this.auth.checkLogin().then(isAuthenticated => {
return this.authService.checkLogin().then(isAuthenticated => {
if (!isAuthenticated) {
this.router.navigate(['']);
}

4
src/Squidex/app/shared/guards/must-be-not-authenticated.guard.ts

@ -13,13 +13,13 @@ import { AuthService } from './../services/auth.service';
@Injectable()
export class MustBeNotAuthenticatedGuard implements CanActivate {
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly router: Router
) {
}
public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
return this.auth.checkLogin().then(isAuthenticated => {
return this.authService.checkLogin().then(isAuthenticated => {
if (isAuthenticated) {
this.router.navigate(['app']);
}

8
src/Squidex/app/shared/services/apps-store.service.ts

@ -44,10 +44,10 @@ export class AppsStoreService {
}
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly appsService: AppsService
) {
if (!auth || !appsService) {
if (!authService || !appsService) {
return;
}
@ -58,7 +58,7 @@ export class AppsStoreService {
this.lastApps = apps;
});
this.auth.isAuthenticated.subscribe(isAuthenticated => {
this.authService.isAuthenticated.subscribe(isAuthenticated => {
this.isAuthenticated = isAuthenticated;
if (isAuthenticated) {
@ -83,7 +83,7 @@ export class AppsStoreService {
public selectApp(name: string | null): Promise<boolean> {
this.appName$.next(name);
return this.selectedApp.take(1).map(app => app !== null).toPromise();
return this.selectedApp.skip(1).map(app => app !== null).toPromise();
}
public createApp(dto: CreateAppDto, now?: DateTime): Observable<AppDto> {

6
src/Squidex/app/shell/pages/home/home-page.component.ts

@ -19,16 +19,16 @@ export class HomePageComponent {
public showLoginError = false;
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly router: Router
) {
}
public login() {
if (this.isIE()) {
this.auth.loginRedirect();
this.authService.loginRedirect();
} else {
this.auth.loginPopup()
this.authService.loginPopup()
.subscribe(() => {
this.router.navigate(['/app']);
}, ex => {

8
src/Squidex/app/shell/pages/internal/profile-menu.component.ts

@ -36,7 +36,7 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
public profileUrl = this.apiUrl.buildUrl('/identity-server/account/profile');
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly apiUrl: ApiUrlConfig
) {
}
@ -47,9 +47,9 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
public ngOnInit() {
this.authenticationSubscription =
this.auth.isAuthenticated.take(1)
this.authService.isAuthenticated.take(1)
.subscribe(() => {
const user = this.auth.user;
const user = this.authService.user;
if (user) {
this.profileId = user.id;
@ -61,6 +61,6 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
}
public logout() {
this.auth.logoutRedirect();
this.authService.logoutRedirect();
}
}

4
src/Squidex/app/shell/pages/login/login-page.component.ts

@ -16,13 +16,13 @@ import { AuthService } from 'shared';
})
export class LoginPageComponent implements OnInit {
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly router: Router
) {
}
public ngOnInit() {
this.auth.loginRedirectComplete()
this.authService.loginRedirectComplete()
.subscribe(
() => {
this.router.navigate(['/app'], { replaceUrl: true });

4
src/Squidex/app/shell/pages/logout/logout-page.component.ts

@ -16,13 +16,13 @@ import { AuthService } from 'shared';
})
export class LogoutPageComponent implements OnInit {
constructor(
private readonly auth: AuthService,
private readonly authService: AuthService,
private readonly router: Router
) {
}
public ngOnInit() {
this.auth.logoutRedirectComplete()
this.authService.logoutRedirectComplete()
.subscribe(
() => {
this.router.navigate(['/'], { replaceUrl: true });

Loading…
Cancel
Save