Merge lp:~stevenk/launchpad/loggerhead-reject-no-sreg into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 16459
Proposed branch: lp:~stevenk/launchpad/loggerhead-reject-no-sreg
Merge into: lp:launchpad
Diff against target: 25 lines (+9/-2)
1 file modified
lib/launchpad_loggerhead/app.py (+9/-2)
To merge this branch: bzr merge lp:~stevenk/launchpad/loggerhead-reject-no-sreg
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+145760@code.launchpad.net

Commit message

If the sreg_info is None in the Loggerhead glue, log and raise a 401, rather than OOPSing.

Description of the change

If the sreg_info is None, log and raise a 401, rather than OOPSing.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/launchpad_loggerhead/app.py'
2--- lib/launchpad_loggerhead/app.py 2012-08-15 20:57:12 +0000
3+++ lib/launchpad_loggerhead/app.py 2013-01-31 01:31:22 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 import logging
10@@ -138,7 +138,14 @@
11 if response.status == SUCCESS:
12 self.log.error('open id response: SUCCESS')
13 sreg_info = SRegResponse.fromSuccessResponse(response)
14- print sreg_info
15+ if not sreg_info:
16+ self.log.error('sreg_info is None.')
17+ exc = HTTPUnauthorized()
18+ exc.explanation = (
19+ "You don't have a Launchpad account. Check that you're "
20+ "logged in as the right user, or log into Launchpad and try "
21+ "again.")
22+ raise exc
23 environ[self.session_var]['user'] = sreg_info['nickname']
24 raise HTTPMovedPermanently(query['back_to'])
25 elif response.status == FAILURE: