@@ -82,15 +82,16 @@ def __init__(self, id_type=IdentityTypes.adobeID, email=None, username=None, dom
8282 raise ArgumentError ("Identity type (%s) must be one of %s" % (id_type , [i .name for i in IdentityTypes ]))
8383 self .id_type = id_type
8484 self .email = None
85- self .domain = domain
85+ self .domain = None
8686 if username is not None :
8787 if email and username .lower () == email .lower ():
8888 # ignore the username if it's the same as the email (policy default)
8989 username = None
90- if domain :
91- self .domain = domain
9290 elif id_type is not IdentityTypes .federatedID :
9391 raise ArgumentError ("Username must match email except for Federated ID" )
92+ else :
93+ if domain :
94+ self .domain = domain
9495 if email is not None :
9596 if '@' not in email :
9697 raise ArgumentError ("Invalid email address: %s" % email )
@@ -164,8 +165,12 @@ def update(self, email=None, username=None, first_name=None, last_name=None, cou
164165 :param country: new country for this user
165166 :return: the User, so you can do User(...).update(...).add_to_groups(...)
166167 """
167- if self .id_type != IdentityTypes .federatedID and email != username :
168- raise ArgumentError ("Username and email address must match except for Federated ID types" )
168+ if username and self .id_type != IdentityTypes .federatedID :
169+ raise ArgumentError ("You cannot set username except for a federated ID" )
170+ if username and not email :
171+ raise ArgumentError ("Cannot update username when email is not specified" )
172+ if email and username and email .lower () == username .lower ():
173+ raise ArgumentError ("Specify just email to set both email and username for a federated ID" )
169174 updates = {}
170175 for k , v in six .iteritems (dict (email = email , username = username ,
171176 firstname = first_name , lastname = last_name ,
0 commit comments