Example #1
0
        private static AuthUserDatabase Initialize()
        {
            var database = new AuthUserDatabase();

            long adminRoleId = 1;
            long pendingRegistrationRoleId = 2;
            long registeredUserRoleId      = 3;

            database.AddRole(adminRoleId, Role.ADMIN_ROLENAME,
                             Permissions.All.Except(Permissions.IgnoredByAdmins).Select(p => p.Value).ToArray());
            database.AddRole(pendingRegistrationRoleId, Role.PENDING_REGISTRATION_ROLENAME,
                             new[] { Permissions.PendingRegistration.Value });
            database.AddRole(registeredUserRoleId, Role.REGISTERED_USER_ROLENAME,
                             new[] { Permissions.PlayGame.Value });

            database.AddAuthUser(UserDatabase.AdminId, Username.ADMIN, adminRoleId, registeredUserRoleId);
            database.AddAuthUser(UserDatabase.UserId, "User", registeredUserRoleId);
            database.AddAuthUser(UserDatabase.TheColonelId, "TheColonel", registeredUserRoleId);
            database.AddAuthUser(UserDatabase.MattyId, Username.MATTY, adminRoleId, registeredUserRoleId);
            database.AddAuthUser(UserDatabase.MathyId, "Mathy", registeredUserRoleId);
            database.AddAuthUser(UserDatabase.JackDeHaasId, "JackDeHaas", registeredUserRoleId);
            database.AddAuthUser(UserDatabase.PendingPlayerId, "PendingPlayer", pendingRegistrationRoleId);
            database.AddAuthUser(UserDatabase.TestPlayerBlack, "TestPlayerBlack", registeredUserRoleId);
            database.AddAuthUser(UserDatabase.TestPlayerWhite, "TestPlayerWhite", registeredUserRoleId);

            return(database);
        }
Example #2
0
        public override void Save(AuthUser entity)
        {
            var dbAuthUser = DbAuthUser.FromDomainModel(entity);

            _unitOfWork.Store(dbAuthUser, tran => AuthUserDatabase.Temp(tran).AuthUsersTable);

            foreach (var roleId in entity.RoleIds.Select(r => r.Id))
            {
                var dbAuthUserRole = new DbAuthUserRole {
                    UserId = dbAuthUser.Id,
                    RoleId = roleId
                };
                _unitOfWork.Store(dbAuthUserRole, tran => AuthUserDatabase.Temp(tran).AuthUserRolesTable);
            }
        }
        public override void Save(Role entity)
        {
            var dbRole = DbRole.FromDomainModel(entity);

            _unitOfWork.Store(dbRole, tran => AuthUserDatabase.Temp(tran).RolesTable);

            foreach (var permission in entity.Permissions.Select(p => p.Value))
            {
                var dbPermission = new DbPermissionRole {
                    Permission = permission,
                    RoleId     = dbRole.Id
                };
                _unitOfWork.Store(dbPermission, tran => AuthUserDatabase.Temp(tran).PermissionRolesTable);
            }
        }
Example #4
0
 public static void CreateTempDatabase(ITransaction transaction) => _tempDatabases[transaction] = new AuthUserDatabase();
Example #5
0
        public override void Save(AdminLog entity)
        {
            var dbAdminLog = DbAdminLog.FromDomainModel(entity);

            _unitOfWork.Store(dbAdminLog, tran => AuthUserDatabase.Temp(tran).AdminLogsTable);
        }