I have this code from Yii example
private function _checkAuth()
{
if(!(isset($_SERVER['HTTP_X_USERNAME']) and isset($_SERVER['HTTP_X_PASSWORD']))) {
$this->_sendResponse(401);
}
$username = $_SERVER['HTTP_X_USERNAME'];
$password = $_SERVER['HTTP_X_PASSWORD'];
$user=User::model()->find('LOWER(username)=?',array(strtolower($username)));
$this->_sendResponse('200','$username');
if($user===null) {
$this->_sendResponse(401, 'Error: User Name is invalid');
}
else if(!$user->validatePassword($password)) {
$this->_sendResponse(401, 'Error: User Password is invalid');
}
}
How to configure header information for authentication. How to set HTTP_X_USERNAME and HTTP_X_PASSWORD in a request;
for the name, value and body of the RESTClient addon? Thanks for advance
source
share