From 4ad5af85e20799eda5143120657e131e50aef41d Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 3 Apr 2011 16:38:13 -0500 Subject: [PATCH] Added a check_login command to User --- mediagoblin/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mediagoblin/models.py b/mediagoblin/models.py index b1d63181..af10e795 100644 --- a/mediagoblin/models.py +++ b/mediagoblin/models.py @@ -14,9 +14,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import datetime + from mongokit import Document, Set -import datetime +from mediagoblin.auth import lib as auth_lib class MediaEntry(Document): @@ -61,6 +63,13 @@ class User(Document): 'created': datetime.datetime.utcnow, 'email_verified': False} + def check_login(self, password): + """ + See if a user can login with this password + """ + return auth_lib.bcrypt_check_password( + password, self['pw_hash']) + REGISTER_MODELS = [MediaEntry, User]