Ejemplo n.º 1
0
        public static void SeedInMemory(this AuthDbContext dbContext)
        {
            dbContext.Users.Add(new User("100", "*****@*****.**", "onlinestore1".ToSha256(), true));

            dbContext.UserClaims.AddRange(
                new UserClaim(Guid.NewGuid(), "100", JwtClaimTypes.Subject, "100"),
                new UserClaim(Guid.NewGuid(), "100", JwtClaimTypes.Role, "Customer"),
                new UserClaim(Guid.NewGuid(), "100", JwtClaimTypes.Email, "*****@*****.**")
                );

            dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public static bool ValidatePassword(this AuthDbContext dbContext, string userName, string password)
        {
            var user = dbContext.Users.FirstOrDefault(item => item.Email == userName);

            if (user == null)
            {
                return(false);
            }

            if (user.Password == password.ToSha256())
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
 public static User GetUserByID(this AuthDbContext dbContext, string id)
 => dbContext.Users.FirstOrDefault(item => item.UserID == id);
Ejemplo n.º 4
0
 public static IEnumerable <UserClaim> GetUserClaimsByUserID(this AuthDbContext dbContext, string userID)
 => dbContext.UserClaims.Where(item => item.UserID == userID);
Ejemplo n.º 5
0
 public static User GetUserByUserName(this AuthDbContext dbContext, string userName)
 => dbContext.Users.FirstOrDefault(item => item.Email == userName);