Commit 57380d98 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

astakos: Improve invalid activation code handling

display error message instead of returning a 404 response
parent fa991e61
......@@ -152,7 +152,7 @@ UNKNOWN_USERS = "Unknown users: %s"
UNIQUE_EMAIL_IS_ACTIVE_CONSTRAIN_ERR = (
"More than one account with the same email & 'is_active' field. Error."
)
INVALID_ACTIVATION_KEY = "Invalid activation key."
INVALID_ACTIVATION_KEY = "Invalid or already used activation key."
NEW_EMAIL_ADDR_RESERVED = (
"The new email address you requested is already used by another account. "
"Please provide a different one."
......
......@@ -603,7 +603,9 @@ class TestLocal(TestCase):
r = self.client.get(user.get_activation_url(), follow=True)
# previous code got invalidated
self.assertEqual(r.status_code, 404)
self.assertRedirects(r, reverse('login'))
self.assertContains(r, astakos_messages.INVALID_ACTIVATION_KEY)
self.assertEqual(r.status_code, 200)
user = AstakosUser.objects.get(pk=user.pk)
self.assertEqual(len(get_mailbox(self.helpdesk_email)), 0)
......
......@@ -628,7 +628,8 @@ def activate(request, greeting_email_template_name='im/welcome_email.txt',
user = AstakosUser.objects.select_for_update().\
get(verification_code=token)
except AstakosUser.DoesNotExist:
raise Http404
messages.error(request, astakos_messages.INVALID_ACTIVATION_KEY)
return HttpResponseRedirect(reverse('index'))
if user.email_verified:
message = _(astakos_messages.ACCOUNT_ALREADY_VERIFIED)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment