| 1 |
<?php |
| 2 |
/** |
| 3 |
* Controls Auth |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace Extendify\Library\Controllers; |
| 7 |
|
| 8 |
use Extendify\Http; |
| 9 |
|
| 10 |
if (!defined('ABSPATH')) { |
| 11 |
die('No direct access.'); |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* The controller for dealing registration and authentication |
| 16 |
*/ |
| 17 |
class AuthController |
| 18 |
{ |
| 19 |
|
| 20 |
/** |
| 21 |
* Login a user to extendify - it will return the API key |
| 22 |
* |
| 23 |
* @param \WP_REST_Request $request - The request. |
| 24 |
* @return WP_REST_Response|WP_Error |
| 25 |
*/ |
| 26 |
public static function login($request) |
| 27 |
{ |
| 28 |
$response = Http::post('/login', $request->get_params()); |
| 29 |
return new \WP_REST_Response($response); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Handle registration - It will return the API key. |
| 34 |
* |
| 35 |
* @param \WP_REST_Request $request - The request. |
| 36 |
* @return WP_REST_Response|WP_Error |
| 37 |
*/ |
| 38 |
public static function register($request) |
| 39 |
{ |
| 40 |
$response = Http::post('/register', $request->get_params()); |
| 41 |
return new \WP_REST_Response($response); |
| 42 |
} |
| 43 |
} |
| 44 |
|