Hi @bozkan, you can override the AddToOrganizationUnitAsync method of IdentityUserManager
class and inside of the method simply check the user is in any organization unit or not.
public async override Task AddToOrganizationUnitAsync(IdentityUser user, OrganizationUnit ou)
{
if (user.OrganizationUnits.Any())
{
return;
}
base.AddToOrganizationUnitAsync(user, ou);
}
IdentityUserManager
, see https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services#example-overriding-a-domain-service.
- Yes, I have these lines of code in DBContext.
- I have used IdentityUser and IIdentityUserRepository to gather data for Users and OrganizationUnit with these I want to join based on condition my userdefined two entities.
- I have constructed a class where I have called IIdentityUserRepository, IdentityUser objects using Get method.
Anything I need to change here.
Hi @radhikashrotre, sorry for the late response. Can you share the relevant method that you've tried to join the entities?
Hi @Shoba24, you also need to add return Page();
line after the Alerts.Danger(ex.Message);
to show the error in your UI.
public async Task <IActionResult> OnPostAsync()
{
try
{
//your code
}
catch(Exception ex)
{
Alerts.Danger(ex.Message);
return Page(); //show alert on the page
}
return Redirect("/PurchaseOrders");
}
For other alert types see https://docs.abp.io/en/abp/4.4/UI/AspNetCore/Page-Alerts#alert-types
Hi, sorry for the misunderstanding but you can not trigger a modal like in the above photo. (if you want to trigger it, you need to call the method that throws an exception on the js side).
public async Task <IActionResult> OnPostAsync()
{
try
{
//your code
}
catch(Exception ex)
{
Alerts.Danger(ex.Message); //for other alert types see https://docs.abp.io/en/abp/4.4/UI/AspNetCore/Page-Alerts#alert-types
}
return Redirect("/PurchaseOrders");
}
Hi, can you share the OnPost method of your CreateModal.cshtml file?
Hi @Shoba24, I think you need to use the UserFriendlyException
(https://docs.abp.io/en/abp/4.4/Exception-Handling#user-friendly-exception).
Hi @kresimirm,
If my current user is in two roles "Role1" and "Role2" currentUser.Roles will return string[] that contains one record with stringified '["Role1","Role2"]' so I will have to split or deserialize that string to check if user is in "Role1".
Furthermore, if user is just in one role currentUser.Roles will retrurn "RoleName" as simple string record so your code wont work again becasue it will compare "Role1" with '["Role1","Role2"]' .
.Any
instead of .All
method of Linq in the previous answer, sorry for the misunderstanding. You can use the following code-snippet.public static class CurrentUserExtensions
{
public static bool IsInSpecifiedRoles(this ICurrentUser currentUser, string[] roles)
{
var userRoles = currentUser.Roles;
return userRoles.All(userRole => roles.Contains(userRole));
}
}
IsInRole
method of ICurrentUser
, Otherwise you can use the above code-snippet to check the current user has the all roles that you've specified or not. Or you can implement your own logic for other use-cases.Hi @Neozzz, I will send you the steps to be done via email as soon as possible. If the last changes resolved your problem you can close this question. I will inform you via email.
Hi @Spospisil, you need to override LogoReverseUrl
in YourProjectBrandingProvider
on your *.Web layer.
[Dependency(ReplaceServices = true)]
public class YourProjectBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "YourProjectName";
public override string LogoReverseUrl => "/images/logo/abp-purple.png"; //override LogoReverseUrl
}
I've added an image under wwwroot/images/logo named abp-purple.png. And I've also cleared the cache to see the result.
There are some restrictions to implement impersonation for Blazor WASM.
Related issue: https://github.com/abpframework/abp/issues/9997