Open Closed

ProfileAppService.GetAsync problem #1761


User avatar
0
nikolay.nikolov@solutionking.com created

Hello guys. I have a question. Is it posible to load the profile after custom login with: await ProfileAppService.GetAsync(); and then to update it with ProfileAppService.UpdateAsync(...

When I try to do that I receive an error:

Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.

Here is a part of my code:

await SignInManager.SignInAsync(user, isPersistent: false);

await IdentityServerEvents.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id.ToString(), user.UserName));

then:

var profile = await ProfileAppService.GetAsync(); (this is the exception place)


1 Answer(s)
  • User Avatar
    2
    maliming created
    Support Team Fullstack Developer

    HI

    You can try to use CurrentPrincipalAccessor.Change.

    //ICurrentPrincipalAccessor CurrentPrincipalAccessor;
    
    await SignInManager.SignInAsync(user, isPersistent: false);
    using (CurrentPrincipalAccessor.Change(await SignInManager.CreateUserPrincipalAsync(user)))
    {
        var profile = await ProfileAppService.GetAsync();
    }
    
    
    
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11