Activities of "hung.nguyen"

  • ABP Framework version: v4.0.0
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): no
  • Exception message and stack trace: N/A
  • Steps to reproduce the issue: N/A

Hi,

I have an appservice like this:

    public class UserRoleAppService : StaffAppAppService, IApplicationService
    {
        private ICurrentUser _currentUser;
        private CurrentUser _currentUser1;
        private IdentityUserManager _userManager;

        public UserRoleAppService(ICurrentUser currentUser, CurrentUser currentUser1, IdentityUserManager userManager)
        {
            _currentUser = currentUser;
            _currentUser1 = currentUser1;
            _userManager = userManager;
        }

        public async Task AssignRoleToCurrentUser(string roleName)
        {
            var currentUserEntity = await _userManager.GetByIdAsync(_currentUser.Id.Value);
            await _userManager.SetRolesAsync(currentUserEntity, new[] { roleName });
        }
    }

When I run the asp app, I see the new API

Then in Angular app, I try to call it:

    this.restService.request<any, void>({
      method: 'POST',
      url: `/api/app/user-role/assign-role-to-current-user`,
      body: { roleName: 'STAFF'},
    });

But when I set breakpoint in method AssignRoleToCurrentUser, it is not hit. Seems that the method is not called. (There is no any request in tab Network of Chrome debugger) What do I do wrong here, please help?

  • ** Another question is, when I use swagger to make the request, then in method AssignRoleToCurrentUser I see that currentUser is totally empty. How to fix that to get the currentUser?

If I don't login, then I can invoke the AssignRoleToCurrentUser. But if I login, then it will return 400

About the link you send, I checked but I don't know how to make the modal appear like in the screenshots. Please guide me in more details.

Many thanks

  • ABP Framework version: v4.0.0

  • UI type: Angular

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Seperated (Angular): no

  • Exception message and stack trace:

  • Steps to reproduce the issue: Just run the Angular app, it can not load. And in console you will see the error as in screenshot NullInjectorError: R3InjectorError(AppModule)[ApplicationModule -> ApplicationRef -> ApplicationInitStatus -> InjectionToken Application Initializer -> [object Object] -> ProfilePictureHandler -> ProfilePictureService -> RestService -> InjectionToken CORE_OPTIONS -> InjectionToken CORE_OPTIONS -> InjectionToken CORE_OPTIONS]: NullInjectorError: No provider for InjectionToken CORE_OPTIONS!

    Please help. I'm stuck for this, can not work any more.

    I did try adding InjectionToken to the provider list of AppModule but then it causes another error that can not fix. So I guess that is not the correct way.

I did try clearing the cache, not work

hi, what cache do you mean here? Browser cache or npm cache? I tried as you said, clear the Browser cache, but still not work

hi @Mehmet,

I try your code but I doesn't work. Nothing happens. Could you please check your code?

Hi,

I do the same, but still nothing happens, no alert. I'm still logged in

Is there some thing more I need to check?

Ah it is 4.0.0, not as like as this thread's author. And Tiered (MVC) or Identity Server Seperated (Angular) is No

So, does the version affect the solution?

Hi, I found it in the link you sent. It is just simple like this

import { Component } from '@angular/core'; import { OAuthService } from 'angular-oauth2-oidc';

@Component({ selector: 'app-root', template: <abp-loader-bar></abp-loader-bar> <abp-dynamic-layout></abp-dynamic-layout>, }) export class AppComponent { constructor(private oAuthService: OAuthService) { this.oAuthService.revokeTokenAndLogout(); } }

Thanks for your support

Showing 1 to 10 of 13 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11