Activities of "maliming"

hi

Can you share some code or a project to reproduce this?

liming.ma@volosoft.com

Answer

hi

But I see that the on the email the confirmation link is localhost,

What's the port of this link?

hi

I think you can only do this manually.

hi

I will enhance this in the abp framework.

context.Services.Configure<JsonOptions>(options =>
{
    options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
    options.JsonSerializerOptions.Converters.RemoveAll(x => x is AbpStringToEnumFactory);
    options.JsonSerializerOptions.Converters.Add(new MyAbpStringToEnumFactory());
});
using System;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
using Volo.Abp.Json.SystemTextJson.JsonConverters;

namespace Acme.BookStore;

public class MyAbpStringToEnumFactory : JsonConverterFactory
{
    private readonly JsonNamingPolicy? _namingPolicy;
    private readonly bool _allowIntegerValues;

    public MyAbpStringToEnumFactory()
        : this(namingPolicy: null, allowIntegerValues: true)
    {

    }

    public MyAbpStringToEnumFactory(JsonNamingPolicy? namingPolicy, bool allowIntegerValues)
    {
        _namingPolicy = namingPolicy;
        _allowIntegerValues = allowIntegerValues;
    }

    public override bool CanConvert(Type typeToConvert)
    {
        return typeToConvert.IsEnum;
    }

    public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
    {
        return (JsonConverter)Activator.CreateInstance(
            typeof(MyAbpStringToEnumConverter<>).MakeGenericType(typeToConvert),
            BindingFlags.Instance | BindingFlags.Public,
            binder: null,
            new object?[] { _namingPolicy, _allowIntegerValues },
            culture: null)!;
    }
}

public class MyAbpStringToEnumConverter<T> : JsonConverter<T>
    where T : struct, Enum
{
    private readonly JsonStringEnumConverter _innerJsonStringEnumConverter;

    private JsonSerializerOptions? _readJsonSerializerOptions;
    private JsonSerializerOptions? _writeJsonSerializerOptions;

    public MyAbpStringToEnumConverter()
        : this(namingPolicy: null, allowIntegerValues: true)
    {

    }

    public MyAbpStringToEnumConverter(JsonNamingPolicy? namingPolicy = null, bool allowIntegerValues = true)
    {
        _innerJsonStringEnumConverter = new JsonStringEnumConverter(namingPolicy, allowIntegerValues);
    }

    public override bool CanConvert(Type typeToConvert)
    {
        return typeToConvert.IsEnum;
    }

    public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        _readJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(options, x =>
                x == this ||
                x.GetType() == typeof(AbpStringToEnumFactory),
            _innerJsonStringEnumConverter.CreateConverter(typeToConvert, options));

        return JsonSerializer.Deserialize<T>(ref reader, _readJsonSerializerOptions);
    }

    public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
    {
        _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(options, x =>
                x == this ||
                x.GetType() == typeof(MyAbpStringToEnumFactory),
            _innerJsonStringEnumConverter.CreateConverter(typeof(T), options));

        JsonSerializer.Serialize(writer, value,_writeJsonSerializerOptions);
    }

    public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        return (T)Enum.Parse(typeToConvert, reader.GetString()!);
    }

    public override void WriteAsPropertyName(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
    {
        writer.WritePropertyName(Enum.GetName(typeof(T), value)!);
    }
}

Thanks. I will run and test your project.

hi

Steps or project to reproduce the issue, Thanks.

hi

Please share a test project with me, I will debug it. Thanks

liming.ma@volosoft.com

hi

It seems the user.Claims is null

hi

You can set a random GUID to SecurityStamp You can encrypt the password for PasswordHash

//IPasswordHasher<IdentityUser> 
PasswordHash = PasswordHasher.HashPassword(user, PlainPasswordText);

hi

Can you reproduce it in a new template module and app projects?

Remote checking/debugging is slow.

Thanks.

Showing 5381 to 5390 of 11558 entries
Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 25, 2025, 06:16
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.