Move verification key generation to view
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 25 Dec 2011 19:11:09 +0000 (20:11 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Tue, 27 Dec 2011 19:17:16 +0000 (20:17 +0100)
Instead of creating the email verication key on the db
model as a default for the field, create it in the
registration view.
Now all verification key generation is only in
auth/views.py!

mediagoblin/auth/views.py
mediagoblin/db/mongo/models.py

index 919aa3cd62d993907c0ccc8ee0cb8c4f35b2a493..6617837171f6dc27cf2e78431f90d0219010c5c0 100644 (file)
@@ -84,6 +84,7 @@ def register(request):
             user.email = email
             user.pw_hash = auth_lib.bcrypt_gen_password_hash(
                 request.POST['password'])
+            user.verification_key = unicode(uuid.uuid4())
             user.save(validate=True)
 
             # log the user in
index 0e31fc1c3b6ce815c2205913e49c959be8147809..b068fb06a645574325784ea3a9ebfbfb3cb75bb8 100644 (file)
@@ -15,7 +15,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import datetime
-import uuid
 
 from mongokit import Document
 
@@ -88,7 +87,6 @@ class User(Document):
         'created': datetime.datetime.utcnow,
         'email_verified': False,
         'status': u'needs_email_verification',
-        'verification_key': lambda: unicode(uuid.uuid4()),
         'is_admin': False}
 
     def check_login(self, password):