- ABP Framework version: v8.3.2
- UI Type: Blazor WASM
- Database System: EF Core (PostgreSQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace: Failed to load resource: the server responded with a status of 403 ()
- Steps to reproduce the issue: Create a new User with a username that is the same as another users Email
This error is expected and normal, its failing correctly when attempting to add a new User with some dodgy data.
However its resulting in a big 403 Unhandled Exception, with a full stack trace dumped to the console, and a big "Unhandled Exception" error message to the user for what is basically a validation error.
With the Identity Module the User form as well as the API call and all surrounding work is handled by the ABP libraries, and I can't find any documentation on how to shim in our own exception handling so that we can swallow these kinds of errors and present a nicer and more useful error message to the user.
Is there any way to provide some nicer error messages to the end user from an ABP module that is completely standalone?
6 Answer(s)
-
0
hi
Can you share some screenshots and error logs?
Thanks.
-
0
-
0
-
0
The username in this case was not already taken, but the username does equal the email address of another user so maybe the same error message applies.
-
0
ok, I will fix this and share a temporary solution.
Thanks.
-
0
hi
We will fix this in 9.0
https://github.com/abpframework/abp/pull/21263
You can override the
Volo.Abp.Identity:InvalidUserName
text and add the patch code below to your API website."Volo.Abp.Identity:InvalidUserName": "Username '{0}' is invalid, can only contain letters or digits."
public class Program { public async static Task<int> Main(string[] args) { var identityStrings = (typeof(AbpIdentityResultExtensions) .GetField("IdentityStrings", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance) ?.GetValue(null) ?? new Dictionary<string, string>()).As<Dictionary<string, string>>(); if (identityStrings.ContainsKey("InvalidUserName")) { identityStrings["InvalidUserName"] = "Username '{0}' is invalid."; }
https://abp.io/community/articles/how-to-override-localization-strings-of-depending-modules-ba1oy03l