def _check_max_users(cls): """Check if maximum number of users reached.""" conf = Configuration('global').get('system', {}) max_users = conf.get('max_users', 0) if max_users: nb_users = User._model_class.objects.count() if nb_users >= max_users: raise ValueError('Max number of users reached')
def _check_whitelistes(cls, user): """Check if user is in a white list if apply.""" whitelistes = Configuration('global').get('whitelistes', {}) emails_file = whitelistes.get('user_emails') if emails_file and os.path.isfile(emails_file): with open(emails_file) as f: emails = [x for x in f.read().split('\n') if x] if user.recovery_email in emails: return True else: raise ValueError('user email not in whitelist')