Example #1
0
        public void ChangePassword(
            string plainTextPassword,
            List <string> bannedPasswordLiteralList,
            List <string> bannedPasswordPatternList)
        {
            // Validate format
            UserPassword.ValidateFormat(plainTextPassword);

            // Validate banned list
            UserPassword.ValidateOnBannedList(plainTextPassword, bannedPasswordLiteralList, bannedPasswordPatternList);

            // Set password
            Password = UserPassword.Hash(plainTextPassword);
        }
Example #2
0
        private static void Validate(
            string name,
            string surname,
            string email,
            string plainTextPassword,
            int tenantId)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrWhiteSpace(surname))
            {
                throw new ArgumentNullException(nameof(surname));
            }

            if (string.IsNullOrWhiteSpace(email))
            {
                throw new ArgumentNullException(nameof(email));
            }

            if (plainTextPassword != null && string.IsNullOrWhiteSpace(plainTextPassword))  // Allow null
            {
                throw new ArgumentNullException(nameof(Password));
            }
            else if (plainTextPassword != null)
            {
                UserPassword.ValidateFormat(plainTextPassword);
            }

            if (tenantId < 0)
            {
                throw new ArgumentException("Tenant Id cannot be zero or negative", nameof(tenantId));
            }
        }