def validate_password(user, password):
 err_msg = None
 if settings.FEATURES.get('ENFORCE_PASSWORD_POLICY', False):
  try:
   validate_password_strength(password)
  except ValidationError as err:
   err_msg = (_('Password: ') + '; '.join(err.messages))
 if (not PasswordHistory.is_allowable_password_reuse(user, password)):
  if user.is_staff:
   num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE']
  else:
   num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE']
  err_msg = ungettext('You are re-using a password that you have used recently. You must have {num} distinct password before reusing a previous password.', 'You are re-using a password that you have used recently. You must have {num} distinct passwords before reusing a previous password.', num_distinct).format(num=num_distinct)
 if PasswordHistory.is_password_reset_too_soon(user):
  num_days = settings.ADVANCED_SECURITY_CONFIG['MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS']
  err_msg = ungettext('You are resetting passwords too frequently. Due to security policies, {num} day must elapse between password resets.', 'You are resetting passwords too frequently. Due to security policies, {num} days must elapse between password resets.', num_days).format(num=num_days)
 is_password_valid = (err_msg is None)
 return (is_password_valid, err_msg)

def validate_password ( user , password ) : err_msg = None if settings . FEATURES . get ( 'ENFORCE_PASSWORD_POLICY' , False ) : try : validate_password_strength ( password ) except ValidationError as err : err_msg = ( _ ( 'Password: ' ) + '; ' . join ( err . messages ) ) if ( not PasswordHistory . is_allowable_password_reuse ( user , password ) ) : if user . is_staff : num_distinct = settings . ADVANCED_SECURITY_CONFIG [ 'MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE' ] else : num_distinct = settings . ADVANCED_SECURITY_CONFIG [ 'MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE' ] err_msg = ungettext ( 'You are re-using a password that you have used recently. You must have {num} distinct password before reusing a previous password.' , 'You are re-using a password that you have used recently. You must have {num} distinct passwords before reusing a previous password.' , num_distinct ) . format ( num = num_distinct ) if PasswordHistory . is_password_reset_too_soon ( user ) : num_days = settings . ADVANCED_SECURITY_CONFIG [ 'MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS' ] err_msg = ungettext ( 'You are resetting passwords too frequently. Due to security policies, {num} day must elapse between password resets.' , 'You are resetting passwords too frequently. Due to security policies, {num} days must elapse between password resets.' , num_days ) . format ( num = num_days ) is_password_valid = ( err_msg is None ) return ( is_password_valid , err_msg )
validate whether the password meets all validator requirements .