Posted by jari.hollsten on December 6, 2014 at 7:19pm
I'm new to both services and json.
What I would need to achieve is to have a field on registering a new user to be checked if the value is present in another database using json. And if it is, go ahead registering the user otherwise throw an error message.
Comments
Should this not be handled in
Should this not be handled in the form validation?
anyway it hard to do this safely (either you give the world reading rights for the value your about to check. or you need to employ some other way of logging in for this data.
what is the reason your using ervices for this?
Create a Custom Service Resource
Create a custom service resource (essentially copy the user registration service resource), and set up the external database in settings.php. Then in your resource's callback function, check for the value, then proceed with the normal user registration call.
I would classify that as
I would classify that as "unsafe", and prone to injection.
the idea is not wrong (far from it) but make sure you VALIDATE the input. coming from the user. (which is why I suggested the validate_form hook)
and ask yourself if you need to check the other DB. Can't you utilise that DB as the authenticating source (e.a. the other system probably already has a login property in some way just fetch those and create account in your environment or better yet, just authenticate against that system directly. (like through oauth or something)
Good luck and happy festivities (assuming your one of those pl that has festivities these days)