@@ -82,15 +82,16 @@ def __init__(self, id_type=IdentityTypes.adobeID, email=None, username=None, dom
82
82
raise ArgumentError ("Identity type (%s) must be one of %s" % (id_type , [i .name for i in IdentityTypes ]))
83
83
self .id_type = id_type
84
84
self .email = None
85
- self .domain = domain
85
+ self .domain = None
86
86
if username is not None :
87
87
if email and username .lower () == email .lower ():
88
88
# ignore the username if it's the same as the email (policy default)
89
89
username = None
90
- if domain :
91
- self .domain = domain
92
90
elif id_type is not IdentityTypes .federatedID :
93
91
raise ArgumentError ("Username must match email except for Federated ID" )
92
+ else :
93
+ if domain :
94
+ self .domain = domain
94
95
if email is not None :
95
96
if '@' not in email :
96
97
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
164
165
:param country: new country for this user
165
166
:return: the User, so you can do User(...).update(...).add_to_groups(...)
166
167
"""
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" )
169
174
updates = {}
170
175
for k , v in six .iteritems (dict (email = email , username = username ,
171
176
firstname = first_name , lastname = last_name ,
0 commit comments