Skip to content

Commit

Permalink
Return message generic message when settings variables are not set
Browse files Browse the repository at this point in the history
Signed-off-by: ivermac <[email protected]>
  • Loading branch information
ivermac committed Jul 26, 2018
1 parent abccef2 commit 35590ff
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions onadata/apps/api/viewsets/user_profile_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,15 @@ def monthly_submissions(self, request, *args, **kwargs):

@action(detail=False)
def verify_email(self, request, *args, **kwargs):
webhook = settings.EMAIL_VERIFICATION_WEBHOOK
redirect_url = settings.POST_EMAIL_VERIFICATION_REDIRECT_URL
webhook = getattr(settings, "EMAIL_VERIFICATION_WEBHOOK", None)
redirect_url = getattr(settings,
"POST_EMAIL_VERIFICATION_REDIRECT_URL",
None)
verified_key_text = getattr(settings, "VERIFIED_KEY_TEXT", None)

if any(v is None for v in [webhook, redirect_url, verified_key_text]):
return Response(_("There was a problem with the system"))

verification_key = request.query_params.get('verification_key')
response_message = _("Missing or invalid verification key")
if verification_key:
Expand All @@ -229,7 +236,7 @@ def verify_email(self, request, *args, **kwargs):
}
r = requests.post(webhook, data=payload)
if r.status_code == 200:
rp.activation_key = settings.VERIFIED_KEY_TEXT
rp.activation_key = verified_key_text
rp.save()
if redirect_url:
return HttpResponseRedirect(redirect_url)
Expand All @@ -242,7 +249,10 @@ def verify_email(self, request, *args, **kwargs):

@action(methods=['POST'], detail=False)
def send_verification_email(self, request, *args, **kwargs):
verified_key_text = settings.VERIFIED_KEY_TEXT
verified_key_text = getattr(settings, "VERIFIED_KEY_TEXT", None)
if not verified_key_text:
return Response(_("There was a problem with the system"))

username = request.data.get('username')
response_message = _("Verification email has NOT been sent")

Expand Down

0 comments on commit 35590ff

Please sign in to comment.