Enforce unique email addresses with user save service
emosbaugh - March 19, 2009 - 21:51
| Project: | Services |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Is this currently possible? If not, wouldn't this be a good feature, or at least a way to check if you are entering a duplicate. Or do I have to write a custom service?
thanks

#1
The user.save service simply calls Drupal's user_save() function, and that function checks for email address uniqueness. When this fails services will return an error (although this error is kind of vague.) Generally services try and work simply as passthroughs to core functions, and since this is how core works it is probably how services should work as well.
#2
I just tested this and unfortunately, when a user is registered through services, email conflicts do not appear to be checked for. I was able to register two users with the same email. When doing so through the normal Drupal web interface, this is caught.
#3
Wow that is really weird, one of us should take a look soon, that should definitely be caught.
#4
I thought maybe it was because I was using Login Toboggan , but nope. I will tell you that I'm using AMFPHP and Flex, for what it's worth, along with the March 31 dev version.
Any idea where the email checking function is? I couldn't see anything obvious in user.module but it seems like it should live in there.
#5
So the email address checking is done in _user_edit_validate() in user.module. Unfortunately this is only called when users are registered through the Drupal admin interface (through a hook called by the validate handler.) Services is just calling user_save(), so this is all bypassed. This should be fixed to use drupal_execute() just like the node.save service does.
#6
I encountered this problem too. Is it going to be fixed?
#7
Raising priority as it affects all user registration functions eg email. However we should keep the existing user save service and add a new user register service as they exist for different cases. User save should error if a user doesn't currently exist as part of this change.
#8
Subscribing.
#9
Subs
#10
Sorry to bump....but any news on this? (I hope I am not coming accros as rude, as I know this an open-source project, with real people, with real lives behind this :-), so a big thank you for all the work already done.)