예제 #1
0
        public Users Login(string username, string password)
        {
            Users user = mongoDatabaseBase.GetCollection <Users>("Users").Find(x => x.UserName == username).FirstOrDefault();

            if (user != null && !string.IsNullOrEmpty(password))
            {
                if (AuthenticatorValidator.MD5HashCompare(password, user.Password))
                {
                    return(user);
                }

                return(null);
            }
            return(null);
        }
예제 #2
0
        public Users Create(Users user)
        {
            Users userModel = new Users();

            userModel.Password = GeneratePass();
            userModel.UserId   = GenerateUserId();
            userModel.UserName = GenerateUserName(user.FirstName, user.LastName);

            user.Password = AuthenticatorValidator.GenerateMD5(userModel.Password);
            user.UserName = userModel.UserName;
            user.UserId   = userModel.UserId;
            mongoDatabaseBase.GetCollection <Users>("Users").InsertOne(user);

            return(userModel);
        }