Exemplo n.º 1
0
        public static bool QueryIsValidStaffLogon(ExchangeDbContext db, string email, string password)
        {
            var user = db.StaffLogons
                       .Where(l => l.Username == email)
                       .Select(l => new { l.Salt, l.PasswordHash })
                       .FirstOrDefault();

            if (user == null)
            {
                return(false);
            }
            return(user.PasswordHash == UWAStaffLogon.HashPassword(password, user.Salt));
        }
Exemplo n.º 2
0
        public static void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder
            .Entity <UWAStaffLogon>()
            .Property(l => l.Role)
            .HasConversion <string>();
            var salt         = UWAStaffLogon.GenerateSalt();
            var passwordHash = UWAStaffLogon.HashPassword("password", salt);

            modelBuilder
            .Entity <UWAStaffLogon>()
            .HasData(new UWAStaffLogon
            {
                Id           = 1,
                Username     = "******",
                PasswordHash = passwordHash,
                Salt         = salt,
                Role         = UWAStaffRole.StudentOffice,
            });
            modelBuilder
            .Entity <UWAStaffLogon>()
            .Property(l => l.Id)
            .ValueGeneratedOnAdd();
        }