mirror of https://github.com/Squidex/squidex.git
21 changed files with 228 additions and 254 deletions
@ -1,61 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.AspNetCore.Mvc.Filters; |
|
||||
using Squidex.Domain.Apps.Entities.Apps; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Squidex.Infrastructure.Commands; |
|
||||
using Squidex.Web; |
|
||||
|
|
||||
namespace Squidex.Areas.Api.Controllers |
|
||||
{ |
|
||||
[Area("Api")] |
|
||||
[ApiController] |
|
||||
[ApiExceptionFilter] |
|
||||
[ApiModelValidation(false)] |
|
||||
public abstract class ApiController : Controller |
|
||||
{ |
|
||||
protected ICommandBus CommandBus { get; } |
|
||||
|
|
||||
protected IAppEntity App |
|
||||
{ |
|
||||
get |
|
||||
{ |
|
||||
var appFeature = HttpContext.Features.Get<IAppFeature>(); |
|
||||
|
|
||||
if (appFeature == null) |
|
||||
{ |
|
||||
throw new InvalidOperationException("Not in a app context."); |
|
||||
} |
|
||||
|
|
||||
return appFeature.App; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
protected Guid AppId |
|
||||
{ |
|
||||
get { return App.Id; } |
|
||||
} |
|
||||
|
|
||||
protected ApiController(ICommandBus commandBus) |
|
||||
{ |
|
||||
Guard.NotNull(commandBus, nameof(commandBus)); |
|
||||
|
|
||||
CommandBus = commandBus; |
|
||||
} |
|
||||
|
|
||||
public override void OnActionExecuting(ActionExecutingContext context) |
|
||||
{ |
|
||||
if (!context.HttpContext.Request.PathBase.StartsWithSegments("/api")) |
|
||||
{ |
|
||||
context.Result = new RedirectResult("/"); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +1,15 @@ |
|||||
<!DOCTYPE html> |
<!DOCTYPE html> |
||||
<html> |
<html> |
||||
|
<head> |
||||
|
<base href="/"> |
||||
|
</head> |
||||
<body> |
<body> |
||||
<script src="/scripts/oidc-client.min.js"></script> |
<script src="./scripts/oidc-client.min.js"></script> |
||||
<script> |
<script> |
||||
Oidc.Log.logger = console; |
Oidc.Log.logger = console; |
||||
Oidc.Log.logLevel = Oidc.Log.INFO; |
Oidc.Log.logLevel = Oidc.Log.INFO; |
||||
|
|
||||
new Oidc.UserManager().signinPopupCallback(); |
new Oidc.UserManager().signinPopupCallback(); |
||||
</script> |
</script> |
||||
</body> |
</body> |
||||
</html> |
</html> |
||||
|
|||||
@ -1,12 +1,15 @@ |
|||||
<!DOCTYPE html> |
<!DOCTYPE html> |
||||
<html> |
<html> |
||||
|
<head> |
||||
|
<base href="/"> |
||||
|
</head> |
||||
<body> |
<body> |
||||
<script src="/scripts/oidc-client.min.js"></script> |
<script src="./scripts/oidc-client.min.js"></script> |
||||
<script> |
<script> |
||||
Oidc.Log.logger = console; |
Oidc.Log.logger = console; |
||||
Oidc.Log.logLevel = Oidc.Log.INFO; |
Oidc.Log.logLevel = Oidc.Log.INFO; |
||||
|
|
||||
new Oidc.UserManager().signinSilentCallback(); |
new Oidc.UserManager().signinSilentCallback(); |
||||
</script> |
</script> |
||||
</body> |
</body> |
||||
</html> |
</html> |
||||
|
|||||
Loading…
Reference in new issue