Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Handle auth failures
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Feb 17, 2016
1 parent 1caaedb commit a1adec0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sentry_jira/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def __init__(self, data=None, *args, **kwargs):

try:
projects_response = jira.get_projects_list()
except JIRAError:
pass
except JIRAError as e:
if e.status_code == 401:
has_credentials = False
else:
projects = projects_response.json
if projects:
Expand All @@ -85,8 +86,9 @@ def __init__(self, data=None, *args, **kwargs):

try:
priorities_response = jira.get_priorities()
except JIRAError:
pass
except JIRAError as e:
if e.status_code == 401:
has_credentials = False
else:
priorities = priorities_response.json
if priorities:
Expand All @@ -97,12 +99,14 @@ def __init__(self, data=None, *args, **kwargs):
if default_project:
try:
meta = jira.get_create_meta_for_project(default_project)
except JIRAError:
except JIRAError as e:
if e.status_code == 401:
has_credentials = False
can_auto_create = False
else:
self.fields["default_issue_type"].choices = JIRAFormUtils.make_choices(meta["issuetypes"])

if not initial.get('password'):
if not has_credentials:
self.fields['password'].required = True
else:
self.fields['password'].help_text = _("Only enter a new password if you wish to update the stored value")
Expand Down

0 comments on commit a1adec0

Please sign in to comment.