Latest stable

This commit is contained in:
Stoyan Zlatev
2023-04-26 12:23:50 +02:00
parent 59c3b92a91
commit 5898bac868
10 changed files with 38 additions and 35 deletions
@@ -16,7 +16,11 @@
var employee = accountService.FindEmployee(userId);
var claims = new List<Claim>();
httpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
httpContext.User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
{
new Claim(ClaimTypes.Name, string.Empty),
new Claim(ClaimTypes.Role, UserRoles.WEB_Anonymous),
}, nameof(Claim), ClaimTypes.Name, ClaimTypes.Role));
if (employee.IsValid)
{
@@ -1,5 +1,9 @@
namespace LaaProductionWeb.App_Infrastructure
{
using LaaProductionWeb.Controllers;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -49,13 +53,23 @@
controllerType = Type.GetType(controllerTypeName, throwOnError: false, ignoreCase: true);
this.RedirectToDefault(controllerType, requestContext.HttpContext.Response);
if (controllerType is null)
{
controllerTypeName = controllerTypeName.Replace(innerPath, string.Empty);
controllerType = Type.GetType(controllerTypeName, throwOnError: false, ignoreCase: true);
}
var controller = this.serviceProvider.GetService(controllerType) as IController;
if (controllerType != null)
{
var controller = this.serviceProvider.GetService(controllerType) as IController;
this.RedirectToDefault(controller, requestContext.HttpContext.Response);
if (controller != null)
{
return controller;
}
}
return controller;
return this.serviceProvider.GetService<HomeController>() as IController;
}
public SessionStateBehavior GetControllerSessionBehavior(RequestContext requestContext, string controllerName)
@@ -3,6 +3,7 @@
public class UserRoles
{
public const string WEB_Admin = nameof(WEB_Admin);
public const string WEB_Anonymous = nameof(WEB_Anonymous);
public const string WEB_HeReport = nameof(WEB_HeReport);
public const string WEB_PalettenScan = nameof(WEB_PalettenScan);
public const string WEB_ProdApproval = nameof(WEB_ProdApproval);
@@ -18,10 +18,10 @@
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Production",
url: "Production/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
//routes.MapRoute(
// name: "Production",
// url: "Production/{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.MapRoute(
name: "MVC_Default",
@@ -35,7 +35,7 @@
if (this.HttpContext.SignIn(userId))
{
return this.Redirect($"~{this.Request.UrlReferrer.LocalPath}");
return this.RedirectToAction(nameof(Index));
}
}
@@ -1,14 +0,0 @@
namespace LaaProductionWeb.Controllers.Production
{
using LaaProductionWeb.App_Infrastructure;
using System.Web.Mvc;
[AllowAnonymous]
public class HomeController : NestedController
{
[Route("Production/{viewname}/{count}")]
public ActionResult Index(string viewname, int count)
=> this.NestedView();
}
}
@@ -170,7 +170,6 @@
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\ApprovalsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\Production\HomeController.cs" />
<Compile Include="Controllers\ProtocolController.cs" />
<Compile Include="Controllers\ReportController.cs" />
<Compile Include="Controllers\SearchController.cs" />
@@ -1,4 +1,6 @@
<div class="container my-5 py-5">
@using LaaProductionWeb.App_Infrastructure
<div class="container my-5 py-5">
<div class="row">
<div class="col-12">
<div class="jumbotron">
@@ -30,13 +32,8 @@
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div>@this.ViewContext.HttpContext.Session["UserId"]</div>
<div>@this.ViewContext.HttpContext.Session["Expires"]</div>
</div>
</div>
@if (!this.User.Identity.IsAuthenticated)
@if (this.User.IsInRole(UserRoles.WEB_Anonymous))
{
<div class="row">
<div class="col-5">
@@ -15,7 +15,7 @@
<title>Laatzen Production Web</title>
</head>
<body class="d-flex flex-column vh-100 overflow-hidden">
@if (this.User.Identity.IsAuthenticated)
@if (!this.User.IsInRole(UserRoles.WEB_Anonymous))
{
<nav class="navbar navbar-expand-lg navbar-dark bg-dark shadow-sm">
<div class="container-fluid">
+3 -1
View File
@@ -13,8 +13,10 @@
<system.web>
<compilation debug="true" targetFramework="4.6.2"/>
<httpRuntime targetFramework="4.6.2"/>
<anonymousIdentification enabled="true"/>
<authentication mode="None" />
<authorization>
<allow users="*" />
</authorization>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">