From 0c43334c38ae6faf17988cc9e67d1fde9a0e9846 Mon Sep 17 00:00:00 2001
From: Harry Hughes <hugheshi@cardiff.ac.uk>
Date: Sun, 29 Jan 2023 19:46:12 +0000
Subject: [PATCH] Replace models.py

---
 blog/models.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/blog/models.py b/blog/models.py
index 18840c0..d9dfabb 100644
--- a/blog/models.py
+++ b/blog/models.py
@@ -23,9 +23,7 @@ class User(UserMixin,db.Model):
   email=db.Column(db.String(256), unique=True)
   
   def set_password(self,password):
-    salt = bcrypt.gensalt()
-    hashed_password = bcrypt.hashpw(password.encode(), salt)
-    self.password = hashed_password.decode()
+    self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
 
   def check_password(self,password):
     return bcrypt.checkpw(password.encode(), self.password.encode)
-- 
GitLab