diff options
| author | Michael Merickel <michael@merickel.org> | 2016-02-12 02:22:48 -0600 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2016-02-12 02:22:48 -0600 |
| commit | 574ba1aa6d81498220d123d149192eeba81afee7 (patch) | |
| tree | 270d3aea7e3c68df47bc31c9341f02409def069d /docs/tutorials/wiki2/src | |
| parent | e6e4f655f2abe8d1d5ff63ecd70255094af6de73 (diff) | |
| download | pyramid-574ba1aa6d81498220d123d149192eeba81afee7.tar.gz pyramid-574ba1aa6d81498220d123d149192eeba81afee7.tar.bz2 pyramid-574ba1aa6d81498220d123d149192eeba81afee7.zip | |
update the models chapter with the new user model
Diffstat (limited to 'docs/tutorials/wiki2/src')
| -rw-r--r-- | docs/tutorials/wiki2/src/models/tutorial/models/user.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/docs/tutorials/wiki2/src/models/tutorial/models/user.py b/docs/tutorials/wiki2/src/models/tutorial/models/user.py index 6123a3aad..25b0a8187 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/models/user.py +++ b/docs/tutorials/wiki2/src/models/tutorial/models/user.py @@ -17,12 +17,11 @@ class User(Base): password_hash = Column(Text) - def set_password(self, pw, pre_hashed=False): - if pre_hashed: - pwhash = pw - else: - pwhash = bcrypt.hashpw(pw, bcrypt.gensalt()) + def set_password(self, pw): + pwhash = bcrypt.hashpw(pw, bcrypt.gensalt()) self.password_hash = pwhash def check_password(self, pw): - return bcrypt.hashpw(pw, self.password_hash) == self.password_hash + if self.password_hash is not None: + return bcrypt.hashpw(pw, self.password_hash) == self.password_hash + return False |
