I would like to authenticate a user which exists in an external site.
Here is a use case:
- In Drupal, user enters his username and password and hits submit.
- Drupal tries to find that user in it's system and does not find him. At this point an error message is still premature.
- Drupal then runs a custom function which does a REST call to an external site. The REST call validates the username and password.
- If the username and password pair is valid, the REST call returns a success code.
- I then log him in.
Is this possible? If so, how? What hooks do I need to implement? What method should I call to log a person in?
I can programmatically log a user in via
$form_state['uid'] = <user_id>; user_login_submit(array(), $form_state);
but user_id needs to exists in Drupal for this piece of code to work.
I am using Drupal 7.