Merge remote-tracking branch 'refs/remotes/rodney757/auth_refactor'

Conflicts:
	mediagoblin/auth/views.py
	mediagoblin/edit/forms.py
	mediagoblin/templates/mediagoblin/edit/edit_account.html
This commit is contained in:
Christopher Allan Webber
2013-09-19 16:04:23 -05:00
29 changed files with 463 additions and 168 deletions

View File

@@ -81,6 +81,7 @@ class EditAttachmentsForm(wtforms.Form):
attachment_file = wtforms.FileField(
'File')
class EditCollectionForm(wtforms.Form):
title = wtforms.TextField(
_('Title'),

View File

@@ -24,8 +24,6 @@ add_route('mediagoblin.edit.account', '/edit/account/',
'mediagoblin.edit.views:edit_account')
add_route('mediagoblin.edit.delete_account', '/edit/account/delete/',
'mediagoblin.edit.views:delete_account')
add_route('mediagoblin.edit.pass', '/edit/password/',
'mediagoblin.edit.views:change_pass')
add_route('mediagoblin.edit.verify_email', '/edit/verify_email/',
'mediagoblin.edit.views:verify_email')
add_route('mediagoblin.edit.email', '/edit/email/',

View File

@@ -23,7 +23,6 @@ from werkzeug.utils import secure_filename
from mediagoblin import messages
from mediagoblin import mg_globals
from mediagoblin import auth
from mediagoblin.auth import tools as auth_tools
from mediagoblin.edit import forms
from mediagoblin.edit.lib import may_edit_media
@@ -338,46 +337,6 @@ def edit_collection(request, collection):
'form': form})
@require_active_login
def change_pass(request):
# If no password authentication, no need to change your password
if 'pass_auth' not in request.template_env.globals:
return redirect(request, 'index')
form = forms.ChangePassForm(request.form)
user = request.user
if request.method == 'POST' and form.validate():
if not auth.check_password(
form.old_password.data, user.pw_hash):
form.old_password.errors.append(
_('Wrong password'))
return render_to_response(
request,
'mediagoblin/edit/change_pass.html',
{'form': form,
'user': user})
# Password matches
user.pw_hash = auth.gen_password_hash(
form.new_password.data)
user.save()
messages.add_message(
request, messages.SUCCESS,
_('Your password was changed successfully'))
return redirect(request, 'mediagoblin.edit.account')
return render_to_response(
request,
'mediagoblin/edit/change_pass.html',
{'form': form,
'user': user})
def verify_email(request):
"""
Email verification view for changing email address