Merge pull request #507 from emohandesi/fix/login-redirect-encoding

Fix 500 error page on failed login
This commit is contained in:
Hamid Reza Mohammadi 2026-09-14 15:42:29 +03:30 committed by GitHub
commit ecbf9bdcb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -170,7 +170,9 @@ namespace GanjooRazor.Pages
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
return Redirect($"/login?redirect={Request.Path}&error={JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync())}"); // the API's error text is Persian and Location headers must be ASCII, so it is encoded
string loginError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
return Redirect($"/login?redirect={Uri.EscapeDataString(Request.Path)}&error={Uri.EscapeDataString(loginError ?? "")}");
} }
LoggedOnUserModelEx loggedOnUser = JsonConvert.DeserializeObject<LoggedOnUserModelEx>(await response.Content.ReadAsStringAsync()); LoggedOnUserModelEx loggedOnUser = JsonConvert.DeserializeObject<LoggedOnUserModelEx>(await response.Content.ReadAsStringAsync());