Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "firnas"

yes. Did you figure out what is causing the issue?

I could not find any duplicate records for ActivateEmail method in audit logs. i have created a mobile application and when the user is created the email is send to their email address. When they click on the link from the mobile borwser sometime this issue happens.

Hi,

public async Task ActivateEmail(ActivateEmailInput input)
        {
            var user = await UserManager.GetUserByIdAsync(input.UserId);
            Logger.InfoFormat("user is null: {0}", user == null);
            if (user != null)
            {
                Logger.InfoFormat("user confirmaion code: {0}", user.EmailConfirmationCode);
                Logger.InfoFormat("input confirmaion code: {0}", input.ConfirmationCode);
                Logger.InfoFormat("confirmaion code match: {0}", user.EmailConfirmationCode == input.ConfirmationCode);
            }
            if (user == null || user.EmailConfirmationCode.IsNullOrEmpty() || user.EmailConfirmationCode != input.ConfirmationCode)
            {
                throw new UserFriendlyException(L("InvalidEmailConfirmationCode"), L("InvalidEmailConfirmationCode_Detail"));
            }

            user.IsEmailConfirmed = true;
            user.EmailConfirmationCode = null;

            await UserManager.UpdateAsync(user);
        }
        

I added logging. The issue occures only sometimes. The issue comes frequently on chrome incognito mode.

INFO  2019-07-22 08:46:45,059 [28   ] Authorization.Accounts.AccountAppService - user is null: False
INFO  2019-07-22 08:46:45,059 [28   ] Authorization.Accounts.AccountAppService - user confirmaion code: 
INFO  2019-07-22 08:46:45,059 [28   ] Authorization.Accounts.AccountAppService - input confirmaion code: 9d347ae77dfb4cddb9dc0d5f1219280f
INFO  2019-07-22 08:46:45,059 [28   ] Authorization.Accounts.AccountAppService - confirmaion code match: False

Any idea why this happens?

sure i will try that out and update my findings.

Sorry i cannot share the code.

I managed to insert a record like below, but i am not sure if it is the correct approach,

User user = await UserManager.GetUserByIdAsync(AbpSession.UserId.Value);

        List<Point.ClaimedPosts> claimedPosts = new List<Point.ClaimedPosts>();
        foreach (var post in posts)
        {
            await _claimPostRepository.InsertAsync(new Point.ClaimedPosts { UserId = user.Id, PostId = post.PostId });
        }  

I added the above claimed posts class and added it as a list property in user class. A user can have many claimed posts. I tried to add a list to the user claimed posts property and it threw the error

Hi,

  1. Where can i find the ABP nuget version?
  2. No.

I figured it out. Thanks

Thanks for the response. I will change accordingly and test.

Both the ways did not work.

Below is the unit testing code,

LoginAsDefaultTenantAdmin();

            //arrange
            var mockBusinessDomainService = new Mock<IBusinessDomainService>();
            mockBusinessDomainService.Setup(b => b.GetBusinessFromUser(It.IsAny<long>()))
                .ReturnsAsync(new Business.Business
                {
                    BusinessName = "Test Business",
                    SubscriptionStatus = Enums.SubscriptionStatus.Subscribed.ToString()
                });
            mockBusinessDomainService.Setup(b => b.UpdateBusiness(It.IsAny<string>(), It.IsAny<Business.Business>()))
                .ReturnsAsync(new Business.Business
                {
                    BusinessName = "Test Business",
                    SubscriptionStatus = Enums.SubscriptionStatus.UnSubscribed.ToString()
                });


            IBusinessAppService _businessAppService = new BusinessAppService(
                mockBusinessDomainService.Object,
                Resolve<IObjectMapper>(),
                Resolve<IUnitOfWorkManager>(),
                Resolve<SignInManager>()
                );

            //act
            Task t = _businessAppService.CancelSubscription();

Below is part of the method,

//check for user
            long userId = AbpSession.UserId.GetValueOrDefault();

            if (userId == 0)
            {
                throw new UnauthorizedAccessException();
            }

The user id is always 0. That is the problem.

Showing 11 to 20 of 47 entries