Skip to content

Commit

Permalink
Don't leave user in limbo if they change their username
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Jun 26, 2012
1 parent 2bf11bb commit eac0954
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 11 additions & 6 deletions ckan/lib/base.py
Expand Up @@ -195,12 +195,17 @@ def _identify_user(self):
c.userobj = model.User.by_name(c.user)
if c.userobj is None:
# This occurs when you are logged in, clean db
# and then restart i.e. only really for testers. There is no
# user object, so even though repoze thinks you are logged in
# and your cookie has ckan_display_name, we need to force user
# to logout and login again to get the User object.
c.user = None
self.log.warn('Logout to login')
# and then restart (or when you change your username)
# There is no user object, so even though repoze thinks you
# are logged in and your cookie has ckan_display_name, we
# need to force user to logout and login again to get the
# User object.
session['lang'] = request.environ.get('CKAN_LANG')
session.save()

pth = getattr(request.environ['repoze.who.plugins']\
['friendlyform'], 'logout_handler_path')
h.redirect_to(pth)
else:
c.userobj = self._get_user_for_apikey()
if c.userobj is not None:
Expand Down
7 changes: 4 additions & 3 deletions ckan/templates/user/edit_user_form.html
@@ -1,6 +1,6 @@
<form
id="user-edit"
action=""
<form
id="user-edit"
action=""
method="post"
class="form-horizontal ${'has-errors' if errors else ''}"
xmlns:i18n="http://genshi.edgewall.org/i18n"
Expand Down Expand Up @@ -63,6 +63,7 @@ <h2>Errors in form</h2>
<label for="name" class="control-label">Username</label>
<div class="controls">
<input type="text" name="name" value="${data.get('name','')}" />
<p>Changing your username will log you out, and require you to log back in with the new username</p>
</div>
</div>
</fieldset>
Expand Down

0 comments on commit eac0954

Please sign in to comment.