X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Server%2Fapplication%2Fcontrollers%2Fapi.php;h=9692244ed744bbb4097fc806809b75fd1cd31009;hp=33c8558681489553bc817cb1f065fbf75c78639a;hb=9cddbaf57a215186fee6ed1345adf2a1d066d921;hpb=eea7a7b811c836a253d9d21a6a3897b2963cdc18 diff --git a/Server/application/controllers/api.php b/Server/application/controllers/api.php index 33c8558..9692244 100644 --- a/Server/application/controllers/api.php +++ b/Server/application/controllers/api.php @@ -23,7 +23,7 @@ class Api_Controller extends Controller{ $xml = $this->get_xml(); try { $user = new User_Model($xml->login, $xml->password, $xml->email); - return "OK"; + echo "OK"; } catch (Exception $e) { echo $e->getMessage() . "\n"; @@ -48,4 +48,27 @@ class Api_Controller extends Controller{ } return $xml; } + + /* + * Check that supplied credentials are valid using basic authentication + * + */ + public function login(){ + if (isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])){ + $user = new User_Model(); + if ($user->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) + print "OK"; + else { + header('HTTP/1.0 401 Unauthorized'); + print "Invalid credentials"; + die; + } + } + else { + header('HTTP/1.0 401 Unauthorized'); + print "No credentials supplied"; + die; + } + + } } \ No newline at end of file