Base solution for your next web application

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.

Question

When i click on the email confirmation link send when registering a user, sometimes it thorws a error and sometimes it passes. Can i please know why this is hapenning? The error occures when user clicks the activation link from mobile. After retrying sometimes then it passes.

Please see the audit logs,

If i click the link from the computer web application it pasees.

below is the error received,

Can anyone help on understanding why this issue happens?

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 have added a new property to User class,

public List<ClaimedPosts> ClaimedPosts { get; set; }

Below is the class for claimed points class


public class ClaimedPosts : FullAuditedEntity<long>
    {
        public long UserId { get; set; }

        public string PostId { get; set; }

        [ForeignKey("UserId")]
        public User User { get; set; }
    }

When i try to save related data to the claimed posts it gives the below error,

Abp.Domain.Uow.AbpDbConcurrencyException
  HResult=0x80131500
  Message=Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
  Source=Abp.EntityFrameworkCore
  StackTrace:
   at Abp.EntityFrameworkCore.AbpDbContext.<SaveChangesAsync>d__49.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.&lt;SaveChangesAsync&gt;d__98.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.&lt;SaveChangesInDbContextAsync&gt;d__20.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.&lt;SaveChangesAsync&gt;d__12.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.&lt;CompleteUowAsync&gt;d__14.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Domain.Uow.UnitOfWorkBase.&lt;CompleteAsync&gt;d__61.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Domain.Uow.UnitOfWorkInterceptor.&lt;&gt;c__DisplayClass6_0.&lt;&lt;PerformAsyncUow&gt;b__2>d.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.&lt;AwaitTaskWithPostActionAndFinallyAndGetResult&gt;d__5`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.Users.AbpUserStore`2.&lt;UpdateAsync&gt;d__36.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Identity.UserManager`1.<UpdateUserAsync>d__174.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.Users.AbpUserManager`2.&lt;UpdateAsync&gt;d__52.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at OnePoint.Points.PointsAppService.<SavePointsClaimedPosts>d__5.MoveNext() in D:\SocialRewards2\Trunk\aspnet-core\src\OnePoint.Application\Points\PointsAppService.cs:line 142

Inner Exception 1:
DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.

I figured it out. Thanks

Showing 11 to 20 of 64 entries