Browse Source

Minor bugfixes

pull/1/head
Sebastian 10 years ago
parent
commit
50669cb707
  1. 2
      src/Squidex/Program.cs
  2. 15
      src/Squidex/Startup.cs
  3. 2
      src/Squidex/app/components/layout/profile-menu.component.ts
  4. 10
      src/Squidex/app/shared/services/apps-store.service.spec.ts
  5. 16
      src/Squidex/app/shared/services/apps-store.service.ts
  6. 11
      src/Squidex/app/shared/services/auth.service.ts
  7. 9
      src/Squidex/project.json

2
src/Squidex/Program.cs

@ -16,7 +16,7 @@ namespace Squidex
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseKestrel(k => { k.AddServerHeader = false; })
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()

15
src/Squidex/Startup.cs

@ -67,6 +67,7 @@ namespace Squidex
services.AddMemoryCache();
services.AddOptions();
services.AddRouting();
services.AddResponseCompression();
services.AddWebpackBuilder();
services.Configure<MyMongoDbOptions>(
@ -93,19 +94,21 @@ namespace Squidex
loggerFactory.AddConsole();
loggerFactory.AddDebug();
app.UseResponseCompression();
if (!Environment.IsDevelopment())
{
app.UseMiddleware<SingleUrlsMiddleware>();
}
UseIdentity(app);
UseApi(app);
UseFrontend(app);
MapAndUseIdentity(app);
MapAndUseApi(app);
MapAndUseFrontend(app);
app.UseMyEventStore();
}
private void UseIdentity(IApplicationBuilder app)
private void MapAndUseIdentity(IApplicationBuilder app)
{
app.Map(Constants.IdentityPrefix, identityApp =>
{
@ -127,7 +130,7 @@ namespace Squidex
});
}
private void UseApi(IApplicationBuilder app)
private void MapAndUseApi(IApplicationBuilder app)
{
app.Map(Constants.ApiPrefix, appApi =>
{
@ -145,7 +148,7 @@ namespace Squidex
});
}
private void UseFrontend(IApplicationBuilder app)
private void MapAndUseFrontend(IApplicationBuilder app)
{
if (Environment.IsDevelopment())
{

2
src/Squidex/app/components/layout/profile-menu.component.ts

@ -36,7 +36,7 @@ export class ProfileMenuComponent implements Ng2.OnInit, Ng2.OnDestroy {
public ngOnInit() {
this.authenticationSubscription =
this.auth.isAuthenticatedChanges.subscribe(() => {
this.auth.isAuthenticated.subscribe(() => {
const user = this.auth.user;
if (user) {

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

@ -23,7 +23,7 @@ describe('AppsStoreService', () => {
});
it('should load when authenticated once', () => {
authService.setup(x => x.isAuthenticatedChanges)
authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once());
@ -55,7 +55,7 @@ describe('AppsStoreService', () => {
.returns(() => true)
.verifiable(TypeMoq.Times.once());
authService.setup(x => x.isAuthenticatedChanges)
authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once());
@ -85,7 +85,7 @@ describe('AppsStoreService', () => {
});
it('should add app to cache when created', () => {
authService.setup(x => x.isAuthenticatedChanges)
authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once());
@ -119,7 +119,7 @@ describe('AppsStoreService', () => {
});
it('should not add app to cache when cache is null', () => {
authService.setup(x => x.isAuthenticatedChanges)
authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(false))
.verifiable(TypeMoq.Times.once());
@ -143,7 +143,7 @@ describe('AppsStoreService', () => {
});
it('should select app', () => {
authService.setup(x => x.isAuthenticatedChanges)
authService.setup(x => x.isAuthenticated)
.returns(() => Observable.of(true))
.verifiable(TypeMoq.Times.once());

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

@ -24,20 +24,19 @@ import { AuthService } from './auth.service';
@Ng2.Injectable()
export class AppsStoreService {
private lastApps: AppDto[] | null = null;
private isAuthenticated = false;
private readonly apps$ = new Subject<AppDto[]>();
private readonly appName$ = new BehaviorSubject<string | null>(null);
private readonly appsPublished$ =
this.apps$
.distinctUntilChanged()
.publishReplay(1)
.refCount();
.publishReplay(1);
private readonly selectedApp$ =
this.appsPublished$.combineLatest(this.appName$, (apps, name) => apps && name ? apps.find(x => x.name === name) || null : null)
.distinctUntilChanged()
.publishReplay(1)
.refCount();
.publishReplay(1);
public get apps(): Observable<AppDto[]> {
return this.appsPublished$;
@ -55,11 +54,16 @@ export class AppsStoreService {
return;
}
this.selectedApp$.connect();
this.appsPublished$.connect();
this.appsPublished$.subscribe(apps => {
this.lastApps = apps;
});
this.auth.isAuthenticatedChanges.subscribe(isAuthenticated => {
this.auth.isAuthenticated.subscribe(isAuthenticated => {
this.isAuthenticated = isAuthenticated;
if (isAuthenticated) {
this.load();
}
@ -67,7 +71,7 @@ export class AppsStoreService {
}
public reload() {
if (this.auth.isAuthenticated) {
if (this.isAuthenticated) {
this.load();
}
}

11
src/Squidex/app/shared/services/auth.service.ts

@ -43,18 +43,13 @@ export class AuthService {
private readonly isAuthenticatedChangedPublished$ =
this.isAuthenticatedChanged$
.distinctUntilChanged()
.publishReplay(1)
.refCount();
.publishReplay(1);
public get user(): Profile | null {
return this.currentUser;
}
public get isAuthenticated(): boolean {
return !!this.currentUser;
}
public get isAuthenticatedChanges(): Observable<boolean> {
public get isAuthenticated(): Observable<boolean> {
return this.isAuthenticatedChangedPublished$;
}
@ -87,6 +82,8 @@ export class AuthService {
this.checkLogin();
}
this.isAuthenticatedChangedPublished$.connect();
}
public checkLogin(): Promise<boolean> {

9
src/Squidex/project.json

@ -3,18 +3,19 @@
"Autofac": "4.1.1",
"Autofac.Extensions.DependencyInjection": "4.0.0",
"IdentityServer4": "1.0.0-rc2",
"IdentityServer4.AspNetIdentity": "1.0.0-rc2",
"IdentityServer4.AccessTokenValidation": "1.0.1-rc2",
"Microsoft.AspNetCore.Identity": "1.0.0",
"IdentityServer4.AspNetIdentity": "1.0.0-rc2",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.Google": "1.0.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.ResponseCompression": "1.0.0-preview2-22573",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
@ -30,13 +31,13 @@
},
"MongoDB.Driver": "2.4.0-beta1",
"OpenCover": "4.6.519",
"ReportGenerator": "2.5.0-beta1",
"Squidex.Core": "1.0.0-*",
"Squidex.Events": "1.0.0-*",
"Squidex.Infrastructure": "1.0.0-*",
"Squidex.Read": "1.0.0-*",
"Squidex.Store.MongoDb": "1.0.0-*",
"Squidex.Write": "1.0.0-*",
"ReportGenerator": "2.5.0-beta1"
"Squidex.Write": "1.0.0-*"
},
"tools": {

Loading…
Cancel
Save