Skip to content

Commit

Permalink
style: fix some minor formatting irregularities
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdh committed Sep 25, 2023
1 parent 18b5e47 commit 1b63ed6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ckanext/ldap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def logout(self):
# In CKAN 2.10.0+, we also need to invoke the toolkit's
# logout_user() command to clean up anything remaining
# on the CKAN side.
if toolkit.check_ckan_version(min_version='2.10.0'):
if toolkit.check_ckan_version(min_version="2.10.0"):
toolkit.logout_user()

# IAuthenticator
Expand Down
17 changes: 10 additions & 7 deletions ckanext/ldap/routes/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,26 @@ def login_success(user_name, came_from):
'''
# Where to send the user after this function ends.
# Initialize this value with the default in CKAN < 2.10.0.
redirect_path = 'user.logged_in'
redirect_path = "user.logged_in"

# In CKAN 2.10.0 (or, more precisely, ckan/ckan PR #6560
# https://github.com/ckan/ckan/pull/6560), repoze.who was replaced by
# flask-login, and the `/user/logged_in` endpoint was removed.
# We need to retrieve the User object for the user and call
# toolkit.login_user().
if toolkit.check_ckan_version(min_version='2.10.0'):
redirect_path = 'home.index'
user_login_path = 'user.login'
err_msg = 'An error occurred while processing your login. Please contact the system administrators.'
if toolkit.check_ckan_version(min_version="2.10.0"):
redirect_path = "home.index"
user_login_path = "user.login"
err_msg = ("An error occurred while processing your login. Please contact the "
"system administrators.")

try:
# Look up the CKAN User object for user_name
user_obj = User.by_name(user_name)
except toolkit.ObjectNotFound as err:
log.error('User.by_name(%s) raised ObjectNotFound error: %s', user_name, err)
log.error(
"User.by_name(%s) raised ObjectNotFound error: %s", user_name, err
)
toolkit.h.flash_error(err_msg)
return toolkit.redirect_to(user_login_path)

Expand All @@ -89,7 +92,7 @@ def login_success(user_name, came_from):
return toolkit.redirect_to(user_login_path)

# Update the session & redirect
session['ckanext-ldap-user'] = user_name
session["ckanext-ldap-user"] = user_name
session.save()
return toolkit.redirect_to(redirect_path, came_from=came_from)

Expand Down

0 comments on commit 1b63ed6

Please sign in to comment.