0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-18 07:52:56 +01:00

Unpack dictionary in for loop for nicer syntax

This commit is contained in:
Steven Hammerton 2015-10-12 15:05:34 +01:00
parent ab7f9bb861
commit 83b464e4f7

View file

@ -127,16 +127,16 @@ class LoginRestServlet(ClientV1RestServlet):
def do_cas_login(self, cas_response_body):
user, attributes = self.parse_cas_response(cas_response_body)
for required_attribute in self.cas_required_attributes:
for required_attribute, required_value in self.cas_required_attributes.items():
# If required attribute was not in CAS Response - Forbidden
if required_attribute not in attributes:
raise LoginError(401, "Unauthorized", errcode=Codes.UNAUTHORIZED)
# Also need to check value
if self.cas_required_attributes[required_attribute] is not None:
actualValue = attributes[required_attribute]
if required_value is not None:
actual_value = attributes[required_attribute]
# If required attribute value does not match expected - Forbidden
if self.cas_required_attributes[required_attribute] != actualValue:
if required_value != actual_value:
raise LoginError(401, "Unauthorized", errcode=Codes.UNAUTHORIZED)
user_id = UserID.create(user, self.hs.hostname).to_string()