Merge branch 'pre-auth' into basic_auth

Conflicts:
	mediagoblin/auth/tools.py
	mediagoblin/auth/views.py
	mediagoblin/plugins/basic_auth/tools.py
This commit is contained in:
Rodney Ewing 2013-05-27 09:04:53 -07:00
commit 0ccc722ddc
3 changed files with 61 additions and 40 deletions

View File

@ -31,6 +31,8 @@ _log = logging.getLogger(__name__)
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)
_log = logging.getLogger(__name__)
def normalize_user_or_email_field(allow_email=True, allow_user=True): def normalize_user_or_email_field(allow_email=True, allow_user=True):
""" """
@ -126,6 +128,36 @@ def send_verification_email(user, request):
rendered_email) rendered_email)
EMAIL_FP_VERIFICATION_TEMPLATE = (
u"http://{host}{uri}?"
u"userid={userid}&token={fp_verification_key}")
def send_fp_verification_email(user, request):
"""
Send the verification email to users to change their password.
Args:
- user: a user object
- request: the request
"""
rendered_email = render_template(
request, 'mediagoblin/auth/fp_verification_email.txt',
{'username': user.username,
'verification_url': EMAIL_FP_VERIFICATION_TEMPLATE.format(
host=request.host,
uri=request.urlgen('mediagoblin.auth.verify_forgot_password'),
userid=unicode(user.id),
fp_verification_key=user.fp_verification_key)})
# TODO: There is no error handling in place
send_email(
mg_globals.app_config['email_sender_address'],
[user.email],
'GNU MediaGoblin - Change forgotten password!',
rendered_email)
def basic_extra_validation(register_form, *args): def basic_extra_validation(register_form, *args):
users_with_username = User.query.filter_by( users_with_username = User.query.filter_by(
username=register_form.username.data).count() username=register_form.username.data).count()
@ -166,36 +198,6 @@ def register_user(request, register_form):
return None return None
EMAIL_FP_VERIFICATION_TEMPLATE = (
u"http://{host}{uri}?"
u"userid={userid}&token={fp_verification_key}")
def send_fp_verification_email(user, request):
"""
Send the verification email to users to change their password.
Args:
- user: a user object
- request: the request
"""
rendered_email = render_template(
request, 'mediagoblin/auth/fp_verification_email.txt',
{'username': user.username,
'verification_url': EMAIL_FP_VERIFICATION_TEMPLATE.format(
host=request.host,
uri=request.urlgen('mediagoblin.auth.verify_forgot_password'),
userid=unicode(user.id),
fp_verification_key=user.fp_verification_key)})
# TODO: There is no error handling in place
send_email(
mg_globals.app_config['email_sender_address'],
[user.email],
'GNU MediaGoblin - Change forgotten password!',
rendered_email)
def check_login_simple(username, password, username_might_be_email=False): def check_login_simple(username, password, username_might_be_email=False):
user = auth.get_user(username) user = auth.get_user(username)
if not user: if not user:

View File

@ -120,16 +120,7 @@
{% block mediagoblin_content %} {% block mediagoblin_content %}
{% endblock mediagoblin_content %} {% endblock mediagoblin_content %}
</div> </div>
{%- block mediagoblin_footer %} {%- include "mediagoblin/bits/base_footer.html" %}
<footer>
{% trans -%}
Powered by <a href="http://mediagoblin.org/" title='Version {{ version }}'>MediaGoblin</a>, a <a href="http://gnu.org/">GNU</a> project.
{%- endtrans %}
{% trans source_link=app_config['source_link'] -%}
Released under the <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPL</a>. <a href="{{ source_link }}">Source code</a> available.
{%- endtrans %}
</footer>
{%- endblock mediagoblin_footer %}
</div> </div>
{%- endblock mediagoblin_body %} {%- endblock mediagoblin_body %}
{% include 'mediagoblin/bits/body_end.html' %} {% include 'mediagoblin/bits/body_end.html' %}

View File

@ -0,0 +1,28 @@
{#
# GNU MediaGoblin -- federated, autonomous media hosting
# Copyright (C) 2011-2013 MediaGoblin contributors. See AUTHORS.
#
# 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/>.
#}
{%- block mediagoblin_footer %}
<footer>
{% trans -%}
Powered by <a href="http://mediagoblin.org/" title='Version {{ version }}'>MediaGoblin</a>, a <a href="http://gnu.org/">GNU</a> project.
{%- endtrans %}
{% trans source_link=app_config['source_link'] -%}
Released under the <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPL</a>. <a href="{{ source_link }}">Source code</a> available.
{%- endtrans %}
</footer>
{%- endblock mediagoblin_footer -%}