Open Closed

password error messages #8664


User avatar
0
LiSong created
  • ABP Framework version: v9.0.0
  • UI Type: MVC
  • Database System: SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I want to make each rule on it's own line so it's clearer to read, Then each can end with a '.' to get ride of the '.,' issue, how can I make the changes?


5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It seems like a problem, I will check it.

  • User Avatar
    0
    LiSong created

    thanks, any updates?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI, you can override the page alerts page

    Create a Default.cshtml file under the Themes/LeptonX/Components/Common/PageAlerts folder in the authserver project.

    @model Volo.Abp.AspNetCore.Mvc.UI.Alerts.AlertList
    @if (Model.Any())
    {
        <div id="AbpPageAlerts">
            @foreach (var alertMessage in Model)
            {
                alertMessage.Text = alertMessage.Text.Replace(".,", "."+Environment.NewLine);
                <abp-alert alert-type="@(alertMessage.Type)" style="white-space: pre-line" dismissible="@alertMessage.Dismissible">@if (alertMessage.Title != null) { <h4>@alertMessage.Title</h4> }@alertMessage.Text</abp-alert>
            }
        </div>
    }
    

  • User Avatar
    0
    LiSong created

    is there a way to customize the error messages? for example we show 4 error messages here for pwd, but is there a way to combine them into one? like here it shows one message for each rule, I want to combine them and shows passwords must be at least 6 characters and must have at least...

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Yes, but the localized text is independent: https://github.com/abpframework/abp/blob/docspatch/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json#L54-L59

    You can override the Register model.

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(RegisterModel))]
    public class MyRegisterModel : RegisterModel
    {
        protected override string GetLocalizeExceptionMessage(Exception exception)
        {
            var message = base.GetLocalizeExceptionMessage(exception);
            if(message.Contains("Passwords must"))
            {
                message = // change message here
            }
            return message;
        }
    }
    
Made with ❤️ on ABP v9.2.0-preview. Updated on January 20, 2025, 07:44