Opened 9 years ago

Closed 9 years ago

#5422 closed defect (fixed)

Resend Verification link fails after recent db updates

Reported by: ayleph Owned by:
Priority: blocker Milestone: 0.9.0
Component: programming Keywords: db
Cc: tsyesika Parent Tickets:

Description

Trying to access the resend verification link results in a server error.

Error - <type 'exceptions.TypeError'>: 'LocalUser' object has no attribute '__getitem__'
URL: https://goblinrefuge.com/mediagoblin/auth/resend_verification/
File '/path/to/mediagoblin-update/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/paste/exceptions/errormiddleware.py', line 144 in __call__
  app_iter = self.application(environ, sr_checker)
File '/path/to/mediagoblin-update/mediagoblin/app.py', line 342 in __call__
  return self.call_backend(environ, start_response)
File '/path/to/mediagoblin-update/lib/python2.7/site-packages/Werkzeug-0.10.1-py2.7.egg/werkzeug/wsgi.py', line 591 in __call__
  return self.app(environ, start_response)
File '/path/to/mediagoblin-update/mediagoblin/app.py', line 276 in call_backend
  return self._finish_call_backend(request, environ, start_response)
File '/path/to/mediagoblin-update/mediagoblin/app.py', line 318 in _finish_call_backend
  response = controller(request)
File '/path/to/mediagoblin-update/mediagoblin/auth/views.py', line 198 in resend_activation
  return redirect(request, "mediagoblin.user_pages.user_home", user=request.user['username'])
TypeError: 'LocalUser' object has no attribute '__getitem__'

Attachments (1)

0001-Fix-issue-5422-Resend-verification-fails.patch (1.1 KB ) - added by ayleph 9 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by ayleph, 9 years ago

Note: user must be logged in first. Otherwise, the resend verification link redirects to a "please log in so we know who you are!" page.

comment:2 by ayleph, 9 years ago

I added a couple of debug lines to mediagoblin/auth/views.py to see what was failing.

--- a/mediagoblin/auth/views.py
+++ b/mediagoblin/auth/views.py
@@ -195,6 +195,8 @@ def resend_activation(request):
             messages.ERROR,
             _("You've already verified your email address!"))
 
+        print("user object is %r", request.user)
+        print("user name is %r", request.user['username'])
         return redirect(request, "mediagoblin.user_pages.user_home", user=request.user['username'])
 
     email_debug_message(request)

I received the following output.

('user object is %r', <LocalUser #5 verified user "machalus">)
Error - <type 'exceptions.TypeError'>: 'LocalUser' object has no attribute '__getitem__'
URL: https://pumpdev.goblinrefuge.com/auth/resend_verification/
File '/srv/mediagoblin/mediagoblin-beta/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/paste/exceptions/errormiddleware.py', line 144 in __call__
  app_iter = self.application(environ, sr_checker)
File '/srv/mediagoblin/mediagoblin-beta/mediagoblin/app.py', line 342 in __call__
  return self.call_backend(environ, start_response)
File '/path/to/mediagoblin/lib/python2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/wsgi.py', line 588 in __call__
  return self.app(environ, start_response)
File '/srv/mediagoblin/mediagoblin-beta/mediagoblin/app.py', line 276 in call_backend
  return self._finish_call_backend(request, environ, start_response)
File '/srv/mediagoblin/mediagoblin-beta/mediagoblin/app.py', line 318 in _finish_call_backend
  response = controller(request)
File '/srv/mediagoblin/mediagoblin-beta/mediagoblin/auth/views.py', line 199 in resend_activation
  print("user name is %r", request.user['username'])
TypeError: 'LocalUser' object has no attribute '__getitem__'

So it seems that request.user['username'] is throwing the error.

comment:3 by ayleph, 9 years ago

It appears that we can no longer use request.user['username'] with the LocalUser object. Instead, we need to use request.user.username. The attached patch seems to fix this issue.

Previously I noted that this issue only occurred when the user was logged in. I'd like to amend that to say that the user had to be both logged in and already active for this error to appear.

comment:4 by ayleph, 9 years ago

Status: newreview

comment:5 by Christopher Allan Webber, 9 years ago

Resolution: fixed
Status: reviewclosed

Applied and pushed, thank you!

Note: See TracTickets for help on using tickets.