Base solution for your next web application

Activities of "omar"

I would like to use the same static roles for tenants. As of now, I have to create the roles for each tenant every time I create a new tenant. I want to share all four roles for all my tenants. Let's say I can the permissions for the "Student" role, I would have to change it for all tenants. I want all roles for tenants to have the same permission.

public static class StaticRoleNames
    {
        public static class Host
        {
            public const string Sysadmin = "Sysadmin";            
        }

        public static class Tenants
        {
            public const string Admin = "Admin";
            public const string Teacher = "Teacher";
            public const string Student = "Student";
            public const string Parent = "Parent";
        }
    }

Thank you!

That worked for me. Thanks

I am having the same issue when using AbpApiController.

public class UsersController : AbpApiController
    {
        private readonly IRepository<User, long> _userRepo;
      
        public UsersController(  IRepository<User,long> userRepo)
        {     
            _userRepo = userRepo;
        }

        [HttpGet]
        [UnitOfWork]
        public virtual dynamic GetAll()
        {
           return _userRepo.GetAllList();
        } 
    }

Is it possible to get the user's role name when quering for a user.

var user =   UserManager.Users.Where(e => e.Id == input.Id)
              .Select(a => new UserEditDto
               {
                    Id = a.Id,
                    FirstName = a.Name,
                    LastName = a.Surname,
                    Email = a.EmailAddress,
                    UserName = a.UserName,                  
                    RoleId = a.Roles.FirstOrDefault().RoleId // i would like Role's name instead
                })
               .FirstOrDefault();

Thanks

Abp user permission to authorize the users. If you are using the attribute [AbpAuthorize("name of permission")] in your controller or action, Abp will authorize the user based on that. You can think of a role as a way to group a number of permissions together. For instance, an Admin role can do CRUD on all users. This can be done with [Authorize(Role="admin)"] from asp.net mvc. The problem is when you need to prevent a particular admin user from doing it all. Let's say you want John to Create, Update but not Delete.

Basically, they serve the "same purpose", but permission give you more granular control. Hope that helps

You should be able to change the name of your table during OnModelCreating. You can overwrite DataAnnotation of the table name . Code-First gives precedence to Fluent API > data annotations > default conventions.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
  
            modelBuilder.Entity<AuditLog>().ToTable("AuditLogs ");
                    
        }

What would be the best place to put an event handler given the template structure downloaded from the site. Core Application Web WebApi

I would like to use the application services created in Project.Application to query information and email the user. How can i handle async actions inside my ExampleEventHandler?

Thanks

I would like to create new users with no emails. Inside my UserManager's constructor, I have the following code:

UserValidator = new UserValidator<User, long>(this)
            {
                 RequireUniqueEmail = false,                
             };

However, I am still getting a validation error with an empty email address.

Thank You!

Thank you for your help. In case anyone need it.

class User

[Required(AllowEmptyStrings=true)]
        public override string EmailAddress { get; set; }

UserManager

public override async Task<IdentityResult> CheckDuplicateUsernameOrEmailAddressAsync(long? expectedUserId, string userName, string emailAddress)
        {
            var user = (await FindByNameAsync(userName));
            if (user != null && user.Id != expectedUserId)
            {
                return AbpIdentityResult.Failed(string.Format("Name {0} is already taken.", userName));
            }

            // if email  address was provided, check that it does not exist
            if (!string.IsNullOrEmpty(emailAddress))
            {
                user = (await FindByEmailAsync(emailAddress));
                if (user != null && user.Id != expectedUserId)
                {
                    return AbpIdentityResult.Failed(string.Format("Email Address {0} is already taken.", emailAddress));
                }
            }

            return IdentityResult.Success;
        }

You mentioned that "this may break login". I was going over the AbpUserManager.cs class, but I was not able to find a problem since the LoginAsyncInternal function use the username or email to login. Any idea where this will break? Thanks again

Showing 1 to 10 of 16 entries