Route('mediagoblin.auth.login', '/login/',
controller='mediagoblin.auth.views:login'),
Route('mediagoblin.auth.logout', '/logout/',
- controller='mediagoblin.auth.views:logout')]
+ controller='mediagoblin.auth.views:logout'),
+ Route('mediagoblin.auth.verify_email', '/verify_email/',
+ controller='mediagoblin.auth.views:verify_email')]
return exc.HTTPFound(
location=request.urlgen("index"))
+
+def verify_email(request):
+ import bson.objectid
+ user = request.db.User.find_one(
+ {'_id': bson.objectid.ObjectId( unicode( request.GET.get('userid') ) )})
+
+ verification_successful = bool
+
+ if user and user['verification_key'] == unicode( request.GET.get('token') ):
+ user['status'] = u'active'
+ user['email_verified'] = True
+ verification_successful = True
+ user.save()
+ else:
+ verification_successful = False
+
+ template = request.template_env.get_template(
+ 'mediagoblin/auth/verify_email.html')
+ return Response(
+ template.render(
+ {'request': request,
+ 'user': user,
+ 'verification_successful': verification_successful}))
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import datetime
+import datetime, uuid
from mongokit import Document, Set
'pw_hash': unicode,
'email_verified': bool,
'status': unicode,
+ 'verification_key': unicode
}
required_fields = ['username', 'created', 'pw_hash', 'email']
default_values = {
'created': datetime.datetime.utcnow,
'email_verified': False,
- # TODO: shouldn't be active by default, must have email registration
- 'status': u'active'}
+ 'status': u'needs_email_verification',
+ 'verification_key': unicode( uuid.uuid4() ) }
def check_login(self, password):
"""
--- /dev/null
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 Free Software Foundation, Inc
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#}
+{% extends "mediagoblin/base.html" %}
+
+{% block mediagoblin_content %}
+<p>
+ {% if verification_successful %}
+ Your email address has been verified!
+ {% else %}
+ The verification key or user id is incorrect
+ {% endif %}
+</p>
+{% endblock %}