<commit_before><?php
/**
 * @version     $Id$
 * @category    Nooku
 * @package     Nooku_Server
 * @subpackage  Users
 * @copyright   Copyright (C) 2011 Timble CVBA and Contributors. (http://www.timble.net).
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Login Controller Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/gergoerdosi>
 * @category    Nooku
 * @package     Nooku_Server
 * @subpackage  Users
 */
class ComUsersControllerLogin extends ComDefaultControllerResource
{
    protected function _actionLogin(KCommandContext $context)
    {
        if($return = KRequest::get('post.return', 'base64'))
        {
            $return = base64_decode($return);

            if(!JURI::isInternal($return)) {
                $return = '';
            }
        }

        $options = array(
            'return'   => $return
        );

        $credentials = array(
            'username' => KRequest::get('post.username', 'string'),
            'password' => KRequest::get('post.password', 'raw')
        );

        $result = JFactory::getApplication()->login($credentials, $options);

        if(!JError::isError($result))
        {
            if(!$return) {
                $return = 'index.php?option=com_users&view=user';
            }

            $this->_redirect = $return;
        }
        else
        {
            if(!$return) {
                $return	= 'index.php?option=com_users&view=login';
            }

            $this->setRedirect($return, $result->getError(), 'error');
        }
    }

	public function getView()
	{
		$view = parent::getView();

		if ($view) 
		{
		    $return = $this->getService('koowa:filter.base64')->sanitize($this->_request->return);
			$view->assign('return', $return);
		}

		return $view;
	}
}<commit_msg>re #176 : Moved login action to user controller. Set status to 401 for none-authorized resources.<commit_after><?php
/**
 * @version     $Id$
 * @category    Nooku
 * @package     Nooku_Server
 * @subpackage  Users
 * @copyright   Copyright (C) 2011 Timble CVBA and Contributors. (http://www.timble.net).
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Login Controller Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/gergoerdosi>
 * @category    Nooku
 * @package     Nooku_Server
 * @subpackage  Users
 */
class ComUsersControllerLogin extends ComDefaultControllerResource
{
    protected function _actionGet(KCommandContext $context)
    {  
        //Set the status
        $context->status = KHttpResponse::UNAUTHORIZED;
           
        return parent::_actionGet($context);
    }
}
{'fraction_non_alphanumeric': 0.14695077149155034, 'fraction_numerical': 0.008082292432035268, 'mean_word_length': 2.3329253365973073, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6605891', 'n_tokens_mistral': 868, 'n_tokens_neox': 830, 'n_words': 157}