<commit_before>from project import db
import datetime, hashlib, random

class User(db.Document):
	created = db.DateTimeField(default=datetime.datetime.now(), required=True)
	email = db.StringField(max_length=255, required=True, unique=True)
	salt = db.StringField(max_length=255, required=True)
	password = db.StringField(max_length=255, required=True)
	roles = db.ListField(db.StringField(max_length=50))

	def hasRole(self,role):
		return role in self.roles

	def addRole(self,role):
		if role not in self.roles:
			self.roles.append(role)
		return self

	def removeRole(self,role):
		if role in self.roles:
			self.roles.remove(role)
		return self	

	def changePassword(self,password):
		self.password =	<PASSWORD>(self.salt.join(password)).hexdigest()
		self.save()
		return self

	@staticmethod
	def createUser(email, password):
		user = User(email=email)
		user.salt = str(random.getrandbits(128))
		user.password = hashlib.sha224(user.salt.join(password)).hexdigest()
		user.save()
		return user

	@staticmethod
	def validateUser(email, password):
		user = User.objects(email=email).first()
		if user == None:
			return None
		password = <PASSWORD>(user.salt.join(password)).<PASSWORD>()
		if user.password == password:
			return user
		else:
			return None

	def __str__(self):
		return self.email

	def __repr__(self):
		return {'created': self.created, 'email': self.email, 'roles': self.roles, 'id':str(self.id)}

	meta = {
		'allow_inheritance': True,
		'indexes': ['-created_at', 'email'],
		'ordering': ['-created_at']<commit_msg>Altered MetaData<commit_after>from project import db
import datetime, hashlib, random

class User(db.Document):
	created = db.DateTimeField(default=datetime.datetime.now(), required=True)
	email = db.StringField(max_length=255, required=True, unique=True)
	salt = db.StringField(max_length=255, required=True)
	password = db.StringField(max_length=255, required=True)
	roles = db.ListField(db.StringField(max_length=50))

	def hasRole(self,role):
		return role in self.roles

	def addRole(self,role):
		if role not in self.roles:
			self.roles.append(role)
		return self

	def removeRole(self,role):
		if role in self.roles:
			self.roles.remove(role)
		return self	

	def changePassword(self,password):
		self.password =	hash<PASSWORD>4(self.salt.join(password)).hexdigest()
		self.save()
		return self

	@staticmethod
	def createUser(email, password):
		user = User(email=email)
		user.salt = str(random.getrandbits(128))
		user.password = hashlib.sha224(user.salt.join(password)).hexdigest()
		user.save()
		return user

	@staticmethod
	def validateUser(email, password):
		user = User.objects(email=email).first()
		if user == None:
			return None
		password = hashlib.sha224(user.salt.join(password)).hexdigest()
		if user.password == password:
			return user
		else:
			return None

	def __str__(self):
		return self.email

	def __repr__(self):
		return {'created': self.created, 'email': self.email, 'roles': self.roles, 'id':str(self.id)}

	meta = {
		'allow_inheritance': True,
		'indexes': ['-created', 'email'],
		'ordering': ['-created']
{'fraction_non_alphanumeric': 0.13999353378596832, 'fraction_numerical': 0.012285806660200453, 'mean_word_length': 4.984526112185686, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5750547', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1041, 'n_words': 226}