I have this code from Yii Example
private function _checkAuth()
{
// Check if we have the USERNAME and PASSWORD HTTP headers set?
if(!(isset($_SERVER['HTTP_X_USERNAME']) and isset($_SERVER['HTTP_X_PASSWORD']))) {
// Error: Unauthorized
$this->_sendResponse(401);
}
$username = $_SERVER['HTTP_X_USERNAME'];
$password = $_SERVER['HTTP_X_PASSWORD'];
// Find the user
$user=User::model()->find('LOWER(username)=?',array(strtolower($username)));
$this->_sendResponse('200','$username');
if($user===null) {
// Error: Unauthorized
$this->_sendResponse(401, 'Error: User Name is invalid');
}
else if(!$user->validatePassword($password)) {
// Error: Unauthorized
$this->_sendResponse(401, 'Error: User Password is invalid');
}
}
How to set header information for authentication.
How to set HTTP_X_USERNAME and HTTP_X_PASSWORD in request;
for the name, value and body of RESTClient addon?
Thank for advance
I understand your question (same as this post in yii forum) relates to the RESTClient addon. To set your headers in the RESTClient addon: use the ‘headers’ functionality:
And the same with X_USERNAME.
HTH,
JM.