Created
September 2, 2015 18:19
-
-
Save wookiecooking/6e7ccb831f4a953198bb to your computer and use it in GitHub Desktop.
Revisions
-
wookiecooking created this gist
Sep 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ router.post('/login', function(req, res) { var client = xmlrpc.createClient({ host: 'https://wordpress.url/xmlrpc.php', port: 80, path: '/'}) client.methodCall('external.login', [req.body.username, req.body.password], function (error, value) { if(value) { req.session.user_id = value; res.send('success'); } else { res.send('Error connecting to server'); } }) }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ // LOGIN VIA NODE add_filter('xmlrpc_methods', 'api_login_method' ); function api_login_method( $methods ) { $methods['external.login'] = 'external_check_login'; return $methods; } function external_check_login( $args ) { $username = $args[0]; $password = $args[1]; $user = wp_authenticate( $username, $password ); if( is_wp_error( $user ) ) { return false; } return $user->id; }