diff --git contrib/logintoboggan_services/logintoboggan_services.info contrib/logintoboggan_services/logintoboggan_services.info new file mode 100644 index 0000000..8acca28 --- /dev/null +++ contrib/logintoboggan_services/logintoboggan_services.info @@ -0,0 +1,6 @@ +name = "LoginToboggan Services Integration" +description = "Integrates LoginToboggan with Services module" +core = "7.x" + +dependencies[] = logintoboggan +dependencies[] = services \ No newline at end of file diff --git contrib/logintoboggan_services/logintoboggan_services.module contrib/logintoboggan_services/logintoboggan_services.module new file mode 100644 index 0000000..9a7644d --- /dev/null +++ contrib/logintoboggan_services/logintoboggan_services.module @@ -0,0 +1,55 @@ + array( + 'actions' => array( + 'logintoboggan' => array( + 'help' => 'Login a user for a new session with their email address or username.', + 'callback' => 'logintoboggan_services_login', + 'args' => array( + array( + 'name' => 'username', + 'type' => 'string', + 'description' => 'A valid username or email address', + 'source' => array('data' => 'username'), + 'optional' => FALSE, + ), + array( + 'name' => 'password', + 'type' => 'string', + 'description' => 'A valid password', + 'source' => array('data' => 'password'), + 'optional' => FALSE, + ), + ), + 'access callback' => 'services_access_menu', + ), + ), + ), + ); + return $definition; +} + +/** + * Resources callback for logintoboggan + */ +function logintoboggan_services_login($username_email, $password){ + //If an email was used, get the username from that + if (valid_email_address($username_email)){ + $account = user_load_by_mail($username_email); + $username = $account->name; + } else { + $username = $username_email; + } + + //Pass through to the existing services callback + module_load_include('inc', 'services', 'resources/user_resource'); + return _user_resource_login($username, $password); +}