Ejemplo n.º 1
0
 public LoginModel(SignInManager <CustomUser> signInManager,
                   ILogger <LoginModel> logger,
                   UserManager <CustomUser> userManager,
                   StartSpelerContext context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _context       = context;
 }
Ejemplo n.º 2
0
        private async Task CreateUserRoles(IServiceProvider serviceProvider)
        {
            RoleManager <IdentityRole> roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();
            StartSpelerContext         connection  = serviceProvider.GetRequiredService <StartSpelerContext>();

            IdentityResult adminResult, spelerResult;

            bool adminCheck, spelerCheck;


            //toekennen admin rol naar de hoofdgebruiker
            // IdentityUser user = connection.Users.FirstOrDefault(u => u.Email == "*****@*****.**");
            List <CustomUser> Admininstrators = connection.Users.Include(x => x.Persoon).Where(x => x.Persoon.IsAdmin == true || x.Persoon.Email == "*****@*****.**").ToList();

            if (Admininstrators.Count <= 0)
            {  // admin rol toevoegen
                adminCheck = await roleManager.RoleExistsAsync("Admin");

                if (!adminCheck)
                {
                    //rol creëren en seeden naar de database
                    adminResult = await roleManager.CreateAsync(new IdentityRole("Admin"));
                }

                foreach (CustomUser user in Admininstrators)
                {
                    DbSet <IdentityUserRole <string> > roles = connection.UserRoles;
                    IdentityRole adminrole = connection.Roles.FirstOrDefault(r => r.Name == "Admin");
                    if (adminrole != null)
                    {
                        if (!roles.Any(ur => ur.UserId == user.Id && ur.RoleId == adminrole.Id))
                        {
                            roles.Add(new IdentityUserRole <string>()
                            {
                                UserId = user.Id, RoleId = adminrole.Id
                            });
                            connection.SaveChanges();
                        }
                    }
                }
            }
            spelerCheck = await roleManager.RoleExistsAsync("Speler");

            if (!spelerCheck)
            {
                //rol creëren en seeden naar de database
                spelerResult = await roleManager.CreateAsync(new IdentityRole("Speler"));

                connection.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 public RegisterModel(
     UserManager <CustomUser> userManager,
     SignInManager <CustomUser> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender,
     StartSpelerContext context,
     RoleManager <IdentityRole> roleManager)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
     _context       = context;
     _roleManager   = roleManager;
 }
Ejemplo n.º 4
0
 public PersoonController(StartSpelerContext context, RoleManager <IdentityRole> roleManager, UserManager <CustomUser> userManager)
 {
     _context     = context;
     _roleManager = roleManager;
     _userManager = userManager;
 }
Ejemplo n.º 5
0
 public GenericRepo(StartSpelerContext context)
 {
     this.context = context;
 }
 public ProductController(StartSpelerContext context)
 {
     _context = context;
 }
Ejemplo n.º 7
0
 public DrankkaartController(StartSpelerContext context)
 {
     _context = context;
 }
 public EvenementController(StartSpelerContext context)
 {
     _context = context;
 }
Ejemplo n.º 9
0
 public BestellingController(StartSpelerContext context)
 {
     _context = context;
 }
Ejemplo n.º 10
0
 public UnitOfWork(StartSpelerContext context)
 {
     _context = context;
 }