Hi,
In our actual application, I made a couple of changes that allow the application to create the local user after authenticating via Azure AD B2C, but the user goes into an infinite loop where the application keeps trying to display the alert to confirm the email address but it never loads.
You can try this:
[ExposeServices(typeof(MyLoginModel))]
public class MyLoginModel : OpenIddictSupportedLoginModel
{
public MyLoginModel(IAuthenticationSchemeProvider schemeProvider, IOptions<AbpAccountOptions> accountOptions, IAbpRecaptchaValidatorFactory recaptchaValidatorFactory, IAccountExternalProviderAppService accountExternalProviderAppService, ICurrentPrincipalAccessor currentPrincipalAccessor, IOptions<IdentityOptions> identityOptions, IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions, AbpOpenIddictRequestHelper openIddictRequestHelper) : base(schemeProvider, accountOptions, recaptchaValidatorFactory, accountExternalProviderAppService, currentPrincipalAccessor, identityOptions, reCaptchaOptions, openIddictRequestHelper)
{
}
protected override async Task<IdentityUser> CreateExternalUserAsync(ExternalLoginInfo info)
{
await IdentityOptions.SetAsync();
var emailAddress = info.Principal.FindFirstValue(AbpClaimTypes.Email) ?? info.Principal.FindFirstValue(ClaimTypes.Email);
var userName = await GetUserNameFromEmail(emailAddress);
var user = new IdentityUser(GuidGenerator.Create(), userName, emailAddress, CurrentTenant.Id);
user.SetEmailConfirmed(true); // set true to skip email confirmation step
(await UserManager.CreateAsync(user)).CheckErrors();
(await UserManager.SetEmailAsync(user, emailAddress)).CheckErrors();
(await UserManager.AddLoginAsync(user, info)).CheckErrors();
(await UserManager.AddDefaultRolesAsync(user)).CheckErrors();
if (emailAddress == "<admin user email>")
{
await UserManager.AddToRoleAsync(user, "admin");// add admin role to admin user
}
user.Name = info.Principal.FindFirstValue(AbpClaimTypes.Name);
user.Surname = info.Principal.FindFirstValue(AbpClaimTypes.SurName);
var phoneNumber = info.Principal.FindFirstValue(AbpClaimTypes.PhoneNumber);
if (!phoneNumber.IsNullOrWhiteSpace())
{
var phoneNumberConfirmed = string.Equals(info.Principal.FindFirstValue(AbpClaimTypes.PhoneNumberVerified), "true", StringComparison.InvariantCultureIgnoreCase);
user.SetPhoneNumber(phoneNumber, phoneNumberConfirmed);
}
await UserManager.UpdateAsync(user);
return user;
}
protected virtual async Task<string> GetUserNameFromEmail(string email)
{
var userName = email.Split('@')[0];
var existUser = await UserManager.FindByNameAsync(userName);
while (existUser != null)
{
var randomUserName = userName + RandomHelper.GetRandom(1000, 9999);
existUser = await UserManager.FindByNameAsync(randomUserName);
if (existUser == null)
{
userName = randomUserName;
break;
}
}
return userName;
}
}
Hi,
I can confirm it. this is a problem with the suite. we will improve the suite in the next patch version. your ticket was refunded.
I have another question, when an event bus - event handler subscribe to an event, if the handler code has exception, the message is kept in the queue and keep sending to handler again and again? Is there a setting to set up the max try times or if handler failed, don't keep the message in the queue. (RabbitMQ distributed event bus)
Yes, the event will be sending to the handler until completed, and there is no such max try times
setting.
If you want to ignore errors in an event handler, you must use a try-catch block in your handler and shouldn't re-throw the exception.
https://docs.abp.io/en/abp/latest/Distributed-Event-Bus#transaction-and-exception-handling
1- We are expecting to change the suite custom code hooks tags in the desired place but it seems not working, is that the intended solution, or this will be fixed?
Can you provide the full steps to reproduce? we will check it.
2- For the other provided solution, I mean overriding the full page, it worked but we have to change the routing at @page as it will conflict with the original page generated by ABP SUIT.
The solution is to custom the module pages, you should use the custom code hooks.
1- If we added a new method in the Partial IXRespository.Extended, and try to add the implementation in the EfCoreXRepository (Eteneded), The EfCoreXRepositoryBase abstract refuses to accept it as an implementation and we have to move it in the abstract class EfCoreXRepository (Base) which again we will remove in case of regeneration. 2- The same if we added a method in IXAppService Extended class, where should we implement it in the controller as it is regenerated each it we regenerate the entity
we will check it. this may be a problem
https://github.com/abpframework/abp/issues/17941
Hi,
I can reproduce this problem, and we will fix it. your ticket was refunded.
You can try abp update
without -v 7.4.0 option to upgrade your project.
Hi,
Could you share the full steps or a project to reproduce the problem? thanks.
Hi,
First:
The event is published in a transaction, it will not be published immediately, but after the transaction is completed, if you want to catch exceptions, you can try it.
try
{
await _distributedEventBus.PublishAsync(new MyEventData()
{
Name = "test"
}, onUnitOfWorkComplete:false);
//Or
//await UnitOfWorkManager.Current.CompleteAsync();
}
catch(Exception e)
{
Logger.LogInformation("PublishAsync error...............: " + e.StackTrace);
}
Second:
By default, the message time out is 300000ms
: https://docs.confluent.io/platform/current/clients/confluent-kafka-dotnet/_site/api/Confluent.Kafka.ProducerConfig.html#Confluent_Kafka_ProducerConfig_MessageTimeoutMs
This means that it will wait for the end of the timeout to throw an exception.
You can config the timeout:
Configure<AbpKafkaOptions>(options =>
{
options.ConfigureProducer = config =>
{
config.MessageTimeoutMs = 60;
};
});
Hi,
Did you install libs (abp install-libs) in web project and node_modules in web project?
Yes, I did.
I have already created this project with abp suite. Ok, I will create new poject with abp suite and then?
Will you get the same error if you deploy to local IIS? Please share it with me if it can be reproduced. thanks.