Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CMService to show additional information #128

Merged
merged 3 commits into from
Sep 7, 2017

Conversation

jkakavas
Copy link
Member

If a logo url/path is available for the requester ( handling happens in the respective frontend ) , send that to the consent service so that it can be shown in the UI.
This is a non breaking change, the use case comes from the InAcademia service.

@@ -103,8 +103,13 @@ def _auth_req_callback_func(self, context, internal_request):
state = context.state
state[STATE_KEY] = {"requester": internal_request.requester}
# TODO consent module should manage any state it needs by itself
context.state[consent.STATE_KEY] = {"filter": internal_request.approved_attributes or [],
"requester_name": internal_request.requester_name}
if consent.STATE_KEY in context.state:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you're trying to do, is add two new values under two new keys under the context.state[consent.STATE_KEY] dict. What I would do is update() the context.state[consent.STATE_KEY] dict with the new key/values in one go.

try:
  state_dict = context.state[consent.STATE_KEY]
except KeyError:
  state_dict = context.state[consent.STATE_KEY] = {}
finally:
  state_dict.update({
    "filter": internal_request.approved_attributes or [],
    "requester_name": internal_request.requester_name,
  })

So, prepare the dict (try/except), and add the values (finally/update).
This makes the code in one block that reads what it wants to achieve and minimizes duplication.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks for the comments. I like this version better too :)

@johanlundberg johanlundberg merged commit 0f16c28 into IdentityPython:master Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants