feat(HomeController): zentralisierte Standard-Kultur-Cookie-Zuweisung.
This commit is contained in:
parent
6d14b79c43
commit
a41d03aed5
@ -48,10 +48,20 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
|
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
|
||||||
public async Task<IActionResult> MainAsync([FromRoute] string envelopeReceiverId)
|
public async Task<IActionResult> MainAsync([FromRoute] string envelopeReceiverId, [FromQuery] string? culture = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//TODO: add a middelware or use an asp.net functionality insead of this code-smell
|
||||||
|
culture = culture is not null ? _sanitizer.Sanitize(culture) : null;
|
||||||
|
envelopeReceiverId = _sanitizer.Sanitize(envelopeReceiverId);
|
||||||
|
|
||||||
|
if (UserLanguage is null && culture is null)
|
||||||
|
{
|
||||||
|
UserLanguage = _cultures.Default.Language;
|
||||||
|
return Redirect($"{Request.Headers["Referer"]}?culture={_cultures.Default.Language}");
|
||||||
|
}
|
||||||
|
|
||||||
envelopeReceiverId = _sanitizer.Sanitize(envelopeReceiverId);
|
envelopeReceiverId = _sanitizer.Sanitize(envelopeReceiverId);
|
||||||
|
|
||||||
if (!envelopeReceiverId.TryDecode(out var decoded))
|
if (!envelopeReceiverId.TryDecode(out var decoded))
|
||||||
@ -99,22 +109,11 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Locked")]
|
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Locked")]
|
||||||
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId, [FromQuery] string? culture = null)
|
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
culture = culture is not null ? _sanitizer.Sanitize(culture) : null;
|
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||||
envelopeReceiverId = _sanitizer.Sanitize(envelopeReceiverId);
|
|
||||||
|
|
||||||
if (UserLanguage is null && culture is null)
|
|
||||||
{
|
|
||||||
UserLanguage = _cultures.Default.Language;
|
|
||||||
return Redirect($"{Request.Headers["Referer"]}?culture={_cultures.Default.Language}");
|
|
||||||
}
|
|
||||||
else if (UserLanguage is not null && culture is not null)
|
|
||||||
return Redirect($"Locked");
|
|
||||||
|
|
||||||
ViewData["UserCulture"] = _cultures[UserLanguage ?? culture];
|
|
||||||
|
|
||||||
return await _envRcvService.IsExisting(envelopeReceiverId: envelopeReceiverId).ThenAsync(
|
return await _envRcvService.IsExisting(envelopeReceiverId: envelopeReceiverId).ThenAsync(
|
||||||
Success: isExisting => isExisting ? View().WithData("EnvelopeKey", envelopeReceiverId) : this.ViewEnvelopeNotFound(),
|
Success: isExisting => isExisting ? View().WithData("EnvelopeKey", envelopeReceiverId) : this.ViewEnvelopeNotFound(),
|
||||||
@ -311,6 +310,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||||
|
|
||||||
readOnlyKey = _sanitizer.Sanitize(readOnlyKey);
|
readOnlyKey = _sanitizer.Sanitize(readOnlyKey);
|
||||||
|
|
||||||
// check if the readOnlyId is valid
|
// check if the readOnlyId is valid
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user