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
Hi, We have already customized the account module (its the only module of which we can download the source code) but we found ourselves needing to implement something similar to the new sessions system found in the identity module. Since both module are correlated and work closely with each other wouldn't it be useful to be able to download the source code of the identity module aswell?
public class Book : AuditedEntity<int>, IHasConcurrencyStamp
{
[NotNull]
public virtual string Title { get; set; }
public virtual int Pages { get; set; }
public virtual DateOnly? PublishDate { get; set; }
public string ConcurrencyStamp { get; set; }
protected Book()
{
}
public Book(string title, int pages, DateOnly? publishDate = null)
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
Check.NotNull(title, nameof(title));
Title = title;
Pages = pages;
PublishDate = publishDate;
}
}
3 Add the data annotations so it would audit only the "PublishDate" property as by the documentation (https://docs.abp.io/en/abp/latest/Audit-Logging#enable-disable-for-entities-properties)
[DisableAuditing]
public class Book : AuditedEntity<int>, IHasConcurrencyStamp
{
[NotNull]
public virtual string Title { get; set; }
public virtual int Pages { get; set; }
[Audited]
public virtual DateOnly? PublishDate { get; set; }
public string ConcurrencyStamp { get; set; }
protected Book()
{
}
public Book(string title, int pages, DateOnly? publishDate = null)
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
Check.NotNull(title, nameof(title));
Title = title;
Pages = pages;
PublishDate = publishDate;
}
}
4 Create a record for the entity 5 Edit the property "Title" of the record 6 In the "Audit logs" page then "Entity Changes" notice how an empty record has been created
It would be helpful if it created the record only when an Audited property is changed.
#region test InsertMany
var myBooks = new List< Book >();
for (var i = 0; i < 12000; i++)
{
myBooks.Add(new Book(i.ToString(),$"Title-{i}"));
}
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
await _bookRepository.InsertManyAsync(myBooks, true);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Console.WriteLine(ts);
#endregion
It takes 60 times longer !!!
We use InsertMany in import jobs and execution times have now gone from a few seconds to many minutes and those that used to take a few minutes now take hours.
We cannot upgrade to 8.1.0 stable because it would block the application in production.
From the release logs there is no evidence of changes in this area.
What has changed?
Description The popup shown with the validations of the form that contains more than one error is displayed in a single line instead of multiple lines.
Reproduction Steps Create a form with inputs and make validations on it
Expected behavior The details of the validation should be multiline
Actual behavior It's displaying in a single line even if it has more than 1 validation
The request is similar to this Issue (but I use blazor WASM instead of MVC): https://github.com/abpframework/abp/issues/19274
If you press the "register" button it will create a new user, this behavior is not correct because it should only let you login if you already have a user in the application, otherwise it should stop you from registering because of the "self registration" setting.
This is due to the filters not getting encoded when the excel api is called.
For LeptonX Theme for Blazor WASM, is it possible to have the right toolbar at the top while keeping the main menu in the left sidebar (to mimic the old Lepton Theme layout)?
We would like to have the same layout and features of ASP.NET ZERO, with the notification component (having the unread notification indicator) and the message component (with the unread message icon) inside the toolbar
By clicking on the notification icon we would like to have a component like the one present in aspnet zero. How could we implement these features (including the notification service inside that)?
We would also like the chat UI to replicate the one present in ASP.NET ZERO, therefore a disappearing chat on the right side. Is it possible and how?
Steps to reproduce the issue:
public static class Level
{
public const string FirstLevel = GroupName + ".FirstLevel";
public const string SecondLevel = FirstLevel + ".SecondLevel";
public const string ThirdLevel = SecondLevel + ".ThirdLevel";
}
var firstLevelPermission = myGroup.AddPermission(PermissionsIssuePermissions.Level.FirstLevel, L("Permission:FirstLevel"));
var secondLevelPermission = firstLevelPermission.AddChild(PermissionsIssuePermissions.Level.SecondLevel, L("Permission:SecondLevel"));
var thirdLevelPermission = secondLevelPermission.AddChild(PermissionsIssuePermissions.Level.ThirdLevel, L("Permission:ThirdLevel"));