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; public callsMax: string | null = null;
constructor(apps: AppsStoreService, notifications: NotificationService, constructor(apps: AppsStoreService, notifications: NotificationService,
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly usagesService: UsagesService private readonly usagesService: UsagesService
) { ) {
super(notifications, apps); super(notifications, apps);
@ -155,8 +155,8 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit,
}); });
this.authenticationSubscription = this.authenticationSubscription =
this.auth.isAuthenticated.subscribe(() => { this.authService.isAuthenticated.subscribe(() => {
const user = this.auth.user; const user = this.authService.user;
if (user) { if (user) {
this.profileDisplayName = user.displayName; 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() @Injectable()
export class MustBeAuthenticatedGuard implements CanActivate { export class MustBeAuthenticatedGuard implements CanActivate {
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly router: Router private readonly router: Router
) { ) {
} }
public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> { public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
return this.auth.checkLogin().then(isAuthenticated => { return this.authService.checkLogin().then(isAuthenticated => {
if (!isAuthenticated) { if (!isAuthenticated) {
this.router.navigate(['']); 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() @Injectable()
export class MustBeNotAuthenticatedGuard implements CanActivate { export class MustBeNotAuthenticatedGuard implements CanActivate {
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly router: Router private readonly router: Router
) { ) {
} }
public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> { public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
return this.auth.checkLogin().then(isAuthenticated => { return this.authService.checkLogin().then(isAuthenticated => {
if (isAuthenticated) { if (isAuthenticated) {
this.router.navigate(['app']); this.router.navigate(['app']);
} }

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

@ -44,10 +44,10 @@ export class AppsStoreService {
} }
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly appsService: AppsService private readonly appsService: AppsService
) { ) {
if (!auth || !appsService) { if (!authService || !appsService) {
return; return;
} }
@ -58,7 +58,7 @@ export class AppsStoreService {
this.lastApps = apps; this.lastApps = apps;
}); });
this.auth.isAuthenticated.subscribe(isAuthenticated => { this.authService.isAuthenticated.subscribe(isAuthenticated => {
this.isAuthenticated = isAuthenticated; this.isAuthenticated = isAuthenticated;
if (isAuthenticated) { if (isAuthenticated) {
@ -83,7 +83,7 @@ export class AppsStoreService {
public selectApp(name: string | null): Promise<boolean> { public selectApp(name: string | null): Promise<boolean> {
this.appName$.next(name); 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> { 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; public showLoginError = false;
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly router: Router private readonly router: Router
) { ) {
} }
public login() { public login() {
if (this.isIE()) { if (this.isIE()) {
this.auth.loginRedirect(); this.authService.loginRedirect();
} else { } else {
this.auth.loginPopup() this.authService.loginPopup()
.subscribe(() => { .subscribe(() => {
this.router.navigate(['/app']); this.router.navigate(['/app']);
}, ex => { }, 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'); public profileUrl = this.apiUrl.buildUrl('/identity-server/account/profile');
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly apiUrl: ApiUrlConfig private readonly apiUrl: ApiUrlConfig
) { ) {
} }
@ -47,9 +47,9 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
public ngOnInit() { public ngOnInit() {
this.authenticationSubscription = this.authenticationSubscription =
this.auth.isAuthenticated.take(1) this.authService.isAuthenticated.take(1)
.subscribe(() => { .subscribe(() => {
const user = this.auth.user; const user = this.authService.user;
if (user) { if (user) {
this.profileId = user.id; this.profileId = user.id;
@ -61,6 +61,6 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
} }
public logout() { 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 { export class LoginPageComponent implements OnInit {
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly router: Router private readonly router: Router
) { ) {
} }
public ngOnInit() { public ngOnInit() {
this.auth.loginRedirectComplete() this.authService.loginRedirectComplete()
.subscribe( .subscribe(
() => { () => {
this.router.navigate(['/app'], { replaceUrl: true }); 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 { export class LogoutPageComponent implements OnInit {
constructor( constructor(
private readonly auth: AuthService, private readonly authService: AuthService,
private readonly router: Router private readonly router: Router
) { ) {
} }
public ngOnInit() { public ngOnInit() {
this.auth.logoutRedirectComplete() this.authService.logoutRedirectComplete()
.subscribe( .subscribe(
() => { () => {
this.router.navigate(['/'], { replaceUrl: true }); this.router.navigate(['/'], { replaceUrl: true });

Loading…
Cancel
Save