feat(HomeController): Kultur-Cookie zur Hauptseite hinzugefügt.
This commit is contained in:
parent
47c7070700
commit
8707a5cdb5
@ -18,6 +18,7 @@ using static EnvelopeGenerator.Common.Constants;
|
|||||||
using Ganss.Xss;
|
using Ganss.Xss;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
{
|
{
|
||||||
@ -49,8 +50,19 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/")]
|
[HttpGet("/")]
|
||||||
public IActionResult Main()
|
public IActionResult Main([FromQuery] string? culture = null)
|
||||||
{
|
{
|
||||||
|
//TODO: add a middelware or use an asp.net functionality insead of this code-smell
|
||||||
|
culture = culture is not null ? _sanitizer.Sanitize(culture) : null;
|
||||||
|
|
||||||
|
if (UserLanguage is null && culture is null)
|
||||||
|
{
|
||||||
|
UserLanguage = _cultures.Default.Language;
|
||||||
|
return Redirect($"{Request.Headers["Referer"]}?culture={_cultures.Default.Language}");
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
@{
|
@{
|
||||||
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
||||||
var userCulture = ViewData["UserCulture"] as Culture;
|
var userCulture = ViewData["UserCulture"] as Culture;
|
||||||
|
//TODO: instead of default assignment add a middleware for culture
|
||||||
|
userCulture ??= _cultures.Default;
|
||||||
var isReadOnly = false;
|
var isReadOnly = false;
|
||||||
if (ViewData["IsReadOnly"] is bool isReadOnly_bool)
|
if (ViewData["IsReadOnly"] is bool isReadOnly_bool)
|
||||||
isReadOnly = isReadOnly_bool;
|
isReadOnly = isReadOnly_bool;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user