Пример #1
0
	def create(self, email, password):
		valid = True
		errors = []
		if(usertools.is_username_valid(getattr(self, 'username', ''))): 
			self.dbuser = DbUser(getattr(self, 'username', ''))
		else:
			self.username = ''
			valid = False 
			error.append('invalid_username')
		
		if(valid and usertools.is_email_valid(email)): 
			self.dbuser.email = email
		else:
			valid = False 
			errors.append('invalid_email')
			
		if(valid and usertools.is_password_valid(password)): 
			salt = usertools.generate_salt()
			encrypted_password = usertools.create_password(self.dbuser.username, salt, self.dbuser.email, password)
			self.dbuser.set_password(encrypted_password, salt)
		else:
			valid = False 
			errors.append('invalid_password')
			
		if (valid): 
			return self.insert()
		else:
			return (False, errors)
Пример #2
0
	def change_password(self, password):
		if (usertools.is_password_valid(password)): 
			salt = usertools.generate_salt()
			encrypted_password = usertools.create_password(self.username, salt, self.email, password)
			dbuser.set_password(encrypted_password, salt)
			return self.update
		else: 
			return (False, ['invalid_password'])
Пример #3
0
	def check_password(password):
		if (usertools.is_password_valid(password)): 
			
	 	else: 
			return False