Esempio n. 1
0
        private async Task <bool> Validate(PermissionConext pcontext, ValidatePermissionDTO input)
        {
            bool haspermission = await(from u in pcontext.User.Where(u => u.Id == input.UserId)
                                       join urm in pcontext.UserRoleMap on u.Id equals urm.UserId
                                       join rmp in pcontext.RolePermissionMap.Where(m => m.Code == input.Code) on urm.RoleId equals rmp.RoleId
                                       join p in pcontext.Permission.Where(per => per.ControllerName == input.Controller && per.ActionName == input.Action) on rmp.PermissionId equals p.Id
                                       select 1).AnyAsync();

            return(haspermission);
        }
Esempio n. 2
0
 private static void EnsureSeedData(PermissionConext context)
 {
     if (!context.User.Any())
     {
         Console.WriteLine("User being populated");
         var adminuser = new UserEntity
         {
             Account       = "superadmin",
             Name          = "superadmin",
             Pwd           = EncryptUtil.GetMd5("666666"),
             IsSystemAdmin = true
         };
         context.User.Add(adminuser);
         context.SaveChanges();
     }
     if (!context.App.Any(a => a.Code == "base"))
     {
         context.App.Add(new AppEntity
         {
             Code = "base",
             Name = "权限系统"
         });
         context.Module.Add(new ModuleEntity
         {
             AppCode = "base",
             Code    = "001",
             Name    = "人员管理"
         });
         context.Module.Add(new ModuleEntity
         {
             AppCode = "base",
             Code    = "002",
             Name    = "系统管理"
         });
         context.Module.Add(new ModuleEntity
         {
             AppCode = "base",
             Code    = "003",
             Name    = "角色管理"
         });
         context.SaveChanges();
     }
 }
Esempio n. 3
0
 public AppController(PermissionConext pcontext)
 {
     this.pcontext = pcontext;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserStore"/> class.
 /// </summary>
 public UserStore(PermissionConext db)
 {
     this.db = db;
 }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="db"></param>
 /// <param name="logger"></param>
 public PasswordValidator(PermissionConext db, ILogger <PasswordValidator> logger)
 {
     this.db     = db;
     this.logger = logger;
 }