With the \fBadmin\fR right any username and property may be specified.
Otherwise the \fBuserinfo\fR right is required and only the
\fBemail\fR and \fBpassword\fR properties may be set.
+.IP
+User properties are syntax-checked before setting. For instance \fBemail\fR
+must contain an "@" sign or you will get an error. (Setting an empty value for
+\fBemail\fR is allowed and removes the property.)
.TP
.B enable
Re-enable further playing, and is the opposite of \fBdisable\fR.
return -1;
}
} else if(!strcmp(key, "email")) {
- if(!strchr(value, '@')) {
- error(0, "invalid email address '%s' for user '%s'", user, value);
- return -1;
- }
+ if(*value) {
+ if(!strchr(value, '@')) {
+ error(0, "invalid email address '%s' for user '%s'", user, value);
+ return -1;
+ }
+ } else
+ value = 0; /* no email -> remove key */
} else if(!strcmp(key, "created")) {
error(0, "cannot change creation date for user '%s'", user);
return -1;
print " checking confirmed user can log in"
jc = disorder.client(user="joe", password="joepass")
jc.version()
+ print " checking new user's email address"
+ assert c.userinfo("joe", "email") == "joe@nowhere.invalid"
+ print " checking can change user email address"
+ c.edituser("joe", "email", "joe@another.invalid")
+ assert c.userinfo("joe", "email") == "joe@another.invalid"
+ print " checking bad email address rejected"
+ try:
+ c.edituser("joe", "email", "invalid")
+ print "*** should not be able to set invalid email address ***"
+ assert False
+ except disorder.operationError:
+ pass # good
+ assert c.userinfo("joe", "email") == "joe@another.invalid"
+ print " checking removal of email address"
+ c.edituser("joe", "email", "")
+ assert c.userinfo("joe", "email") == None
if __name__ == '__main__':
dtest.run()