|  |  | @ -1,3 +1,4 @@ | 
			
		
	
		
			
				
					|  |  |  | from werkzeug.security import generate_password_hash, check_password_hash | 
			
		
	
		
			
				
					|  |  |  | from . import db | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
	
		
			
				
					|  |  | @ -16,6 +17,18 @@ class User(db.Model): | 
			
		
	
		
			
				
					|  |  |  | id = db.Column(db.Integer, primary_key=True) | 
			
		
	
		
			
				
					|  |  |  | username = db.Column(db.String(64), unique=True, index=True) | 
			
		
	
		
			
				
					|  |  |  | role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) | 
			
		
	
		
			
				
					|  |  |  | password_hash = db.Column(db.String(128)) | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | @property | 
			
		
	
		
			
				
					|  |  |  | def password(self): | 
			
		
	
		
			
				
					|  |  |  | raise AttributeError('Password is not a readable attribute') | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | @password.setter | 
			
		
	
		
			
				
					|  |  |  | def password(self, password): | 
			
		
	
		
			
				
					|  |  |  | self.password_hash = generate_password_hash(password) | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | def verify_password(self, password): | 
			
		
	
		
			
				
					|  |  |  | return check_password_hash(self.password_hash, password) | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | def __repr__(self): | 
			
		
	
		
			
				
					|  |  |  | return '<User %r>' % self.username |