summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMichael Merickel <mmerickel@users.noreply.github.com>2016-07-16 17:14:08 -0500
committerGitHub <noreply@github.com>2016-07-16 17:14:08 -0500
commitf169cafa91b20d49aa40124bba90d26e24461517 (patch)
tree5e49fd3f622d15ebcfb21d905e0768b31ae7ce74 /docs
parent950515b5ca2c6f1c0c062284fd48a7ea02b552b4 (diff)
parentba71cf32d543257cf51d1f00104f4a89ca794a42 (diff)
downloadpyramid-f169cafa91b20d49aa40124bba90d26e24461517.tar.gz
pyramid-f169cafa91b20d49aa40124bba90d26e24461517.tar.bz2
pyramid-f169cafa91b20d49aa40124bba90d26e24461517.zip
Merge pull request #2704 from mmerickel/fix/set-password-unicode
fix the wiki2 tutorial to set the password as unicode
Diffstat (limited to 'docs')
-rw-r--r--docs/tutorials/wiki2/src/authentication/tutorial/models/user.py5
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/models/user.py5
-rw-r--r--docs/tutorials/wiki2/src/models/tutorial/models/user.py5
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/models/user.py5
-rw-r--r--docs/tutorials/wiki2/src/views/tutorial/models/user.py5
5 files changed, 10 insertions, 15 deletions
diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py b/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
index 6fb32a1b2..9228b48f7 100644
--- a/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
+++ b/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
@@ -19,11 +19,10 @@ class User(Base):
def set_password(self, pw):
pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
- self.password_hash = pwhash
+ self.password_hash = pwhash.decode('utf8')
def check_password(self, pw):
if self.password_hash is not None:
expected_hash = self.password_hash.encode('utf8')
- actual_hash = bcrypt.hashpw(pw.encode('utf8'), expected_hash)
- return expected_hash == actual_hash
+ return bcrypt.checkpw(pw.encode('utf8'), expected_hash)
return False
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/models/user.py b/docs/tutorials/wiki2/src/authorization/tutorial/models/user.py
index 6fb32a1b2..9228b48f7 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/models/user.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/models/user.py
@@ -19,11 +19,10 @@ class User(Base):
def set_password(self, pw):
pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
- self.password_hash = pwhash
+ self.password_hash = pwhash.decode('utf8')
def check_password(self, pw):
if self.password_hash is not None:
expected_hash = self.password_hash.encode('utf8')
- actual_hash = bcrypt.hashpw(pw.encode('utf8'), expected_hash)
- return expected_hash == actual_hash
+ return bcrypt.checkpw(pw.encode('utf8'), expected_hash)
return False
diff --git a/docs/tutorials/wiki2/src/models/tutorial/models/user.py b/docs/tutorials/wiki2/src/models/tutorial/models/user.py
index 6fb32a1b2..9228b48f7 100644
--- a/docs/tutorials/wiki2/src/models/tutorial/models/user.py
+++ b/docs/tutorials/wiki2/src/models/tutorial/models/user.py
@@ -19,11 +19,10 @@ class User(Base):
def set_password(self, pw):
pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
- self.password_hash = pwhash
+ self.password_hash = pwhash.decode('utf8')
def check_password(self, pw):
if self.password_hash is not None:
expected_hash = self.password_hash.encode('utf8')
- actual_hash = bcrypt.hashpw(pw.encode('utf8'), expected_hash)
- return expected_hash == actual_hash
+ return bcrypt.checkpw(pw.encode('utf8'), expected_hash)
return False
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/models/user.py b/docs/tutorials/wiki2/src/tests/tutorial/models/user.py
index 6fb32a1b2..9228b48f7 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/models/user.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/models/user.py
@@ -19,11 +19,10 @@ class User(Base):
def set_password(self, pw):
pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
- self.password_hash = pwhash
+ self.password_hash = pwhash.decode('utf8')
def check_password(self, pw):
if self.password_hash is not None:
expected_hash = self.password_hash.encode('utf8')
- actual_hash = bcrypt.hashpw(pw.encode('utf8'), expected_hash)
- return expected_hash == actual_hash
+ return bcrypt.checkpw(pw.encode('utf8'), expected_hash)
return False
diff --git a/docs/tutorials/wiki2/src/views/tutorial/models/user.py b/docs/tutorials/wiki2/src/views/tutorial/models/user.py
index 6fb32a1b2..9228b48f7 100644
--- a/docs/tutorials/wiki2/src/views/tutorial/models/user.py
+++ b/docs/tutorials/wiki2/src/views/tutorial/models/user.py
@@ -19,11 +19,10 @@ class User(Base):
def set_password(self, pw):
pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
- self.password_hash = pwhash
+ self.password_hash = pwhash.decode('utf8')
def check_password(self, pw):
if self.password_hash is not None:
expected_hash = self.password_hash.encode('utf8')
- actual_hash = bcrypt.hashpw(pw.encode('utf8'), expected_hash)
- return expected_hash == actual_hash
+ return bcrypt.checkpw(pw.encode('utf8'), expected_hash)
return False