Activities of "roberto.fiocchi"

  • ABP Framework version: v8.2.1
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular):
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Good morning,

I have a Blazor WASM project where I inserted a custom component in the toolbar, following this guide from the doc: https://abp.io/docs/latest/framework/ui/blazor/toolbars#example-add-a-notification-icon

The content of my custom component must be visible only after logging in and with a specific permission, because I need to make API calls when initializing the component, so I need to manage authentication and authorization. To do this I managed everything using the tag "AuthorizeView" (with Policy parameter as explained in the doc) and in the .razor.cs using the "CurrentUser.IsAuthenticated" and the "AuthorizationService.IsGrantedAsync...." inside the "OnInitializedAsync" method. My component code is as follows:

@using AbpSolution1.Books
@using AbpSolution1.Permissions
@using Microsoft.AspNetCore.Authorization
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase
@inject IBooksAppService BooksAppService

@* https://abp.io/docs/latest/framework/ui/blazor/authorization *@
<AuthorizeView Policy="@AbpSolution1Permissions.Books.Default">
    <Authorized>
        @if (IsAnyBook)
        {
            <div class="bg-success w-100 d-flex justify-content-center align-items-center h-100">
                <b class="text-dark" style="font-size: 20px;">
                    Books available
                </b>
            </div>
        }
        else
        {
            <div class="bg-warning w-100 d-flex justify-content-center align-items-center h-100">
                <b class="text-dark" style="font-size: 20px;">
                    No Books
                </b>
            </div>
        }
    </Authorized>
    <NotAuthorized>
        <div class="bg-danger w-100 d-flex justify-content-center align-items-center h-100">
            <b class="text-dark" style="font-size: 20px;">
                Not Authorized
            </b>
        </div>
    </NotAuthorized>
</AuthorizeView>

@code {

    private bool IsAnyBook { get; set; } = false;

    private async Task LoadBooks()
    {
        try
        {
            GetBooksInput input = new GetBooksInput();
            var books = await BooksAppService.GetListAsync(input);
            IsAnyBook = books.Items.Any();
        }
        catch(Exception ex)
        {
            await HandleErrorAsync(ex);
            Console.WriteLine(ex.Message);
        }
    }

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        var isAutheticated = CurrentUser.IsAuthenticated;
        var isAuthorized = await AuthorizationService.IsGrantedAsync(AbpSolution1Permissions.Books.Default);

        if (isAutheticated && isAuthorized)
        {
            await LoadBooks();
        }
    }
}

However, when I log in and the component is rendered I get a 401 "Unauthorized" error, even if the logged in user has permission to make the call. It would appear that the call is made before obtaining the token.

How can I solve it? (if necessary we can attach the entire zipped project)

Thank you, best regards

Roberto

https://github.com/abpframework/abp/issues/20388

Please read https://abp.io/docs/latest/cli/differences-between-old-and-new-cli#using-the-new-abp-cli

Hi @liangshiwei, Now we all must to switch to abp studio because the old cli will no longer be supported, right?

Thanks

Restore the button "Create a new solution" , thanks

I created a new solution using abp cli 8.2.1 and then I installed abp studio and created a new solution always abp 8.2.1 Comparing the two generated solutions I noticed that they are different, obviously excluding the files that abp studio added for its configurations. Why?

With Abp Studio 0.74 I can't choose the preview version of abp. From Abp suite if I choose version 8.3.rc1 from the Abp suite menu and create a new solution it always creates it with the current version: Abp 8.2.1 If I manually install abp suite preview 8.3.rc1 the "Crate a new solution" button is no longer present.

How should I create a new solution with the preview version?

Can you update your example with the final code we should use?

Thank you

Hi liangshiwei, If instead of "https://localhost:44314" you showed how to retrieve the client URL from settings or configuration it would be a better solution

:-)

HI, liangshiwei is this fix also valid for Blazor WASM?

Please update the contents of the page RoadMap https://docs.abp.io/en/commercial/latest/road-map#backlog-items

This page should also be updated https://docs.abp.io/en/commercial/latest/aspnet-zero-vs-abp-commercial

So, we can understand what the next releases will be.

Example, when will this feature be implemented?

Thanks

Showing 21 to 30 of 108 entries
Made with ❤️ on ABP v9.0.0-preview Updated on September 19, 2024, 10:13