<commit_before><?php

namespace Rayku\UserBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

use Rayku\UserBundle\Entity\User;
use Rayku\UserBundle\Form\UserType;

/**
 * User controller.
 */
class UserController extends Controller
{
    /**
     * @ApiDoc(
     *   resource=true,
     *   description="Update a user profile settings",
     *   input="Rayku\UserBundle\Form\UserType"
     * )
     */
    public function postUserAction(User $user)
    {
    	if($user->getId() !== $this->getUser()->getId()){
    		die('access denied');
    		throw new AccessDeniedException();
    	}
    	$request = $this->getRequest();
        $editForm = $this->createForm(new UserType(), $user);
        $editForm->bind($request);

        if ($editForm->isValid()) {
        	$em = $this->getDoctrine()->getEntityManager();
            $em->persist($user);
            $em->flush();
            return $user;
        }
        return array(
            'entity'      => $user,<commit_msg>Throw access denied exception when user doesn't match<commit_after><?php

namespace Rayku\UserBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

use Rayku\UserBundle\Entity\User;
use Rayku\UserBundle\Form\UserType;

/**
 * User controller.
 */
class UserController extends Controller
{
    /**
     * @ApiDoc(
     *   resource=true,
     *   description="Update a user profile settings",
     *   input="Rayku\UserBundle\Form\UserType"
     * )
     */
    public function postUserAction(User $user)
    {
    	if($user->getId() !== $this->getUser()->getId()){
    		throw new AccessDeniedException();
    	}
    	$request = $this->getRequest();
        $editForm = $this->createForm(new UserType(), $user);
        $editForm->bind($request);

        if ($editForm->isValid()) {
        	$em = $this->getDoctrine()->getEntityManager();
            $em->persist($user);
            $em->flush();
            return $user;
        }
        return array(
            'entity'      => $user,
{'fraction_non_alphanumeric': 0.14619110523998238, 'fraction_numerical': 0.0, 'mean_word_length': 2.767827529021559, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6534879', 'n_tokens_mistral': 675, 'n_tokens_neox': 679, 'n_words': 120}