<commit_before><?php

namespace Koddi\Controller;

use Silex\Application;
use Symfony\Component\HttpFoundation\Response;

class AuthController
{
    public function getLogin(Application $app)
    {
        $username = $app['request']->server->get('PHP_AUTH_USER', false);
        $password = $app['request']->server->get('PHP_AUTH_PW');

        $user = $app['userService']->checkCredentials($username, $password);

        if ($user) {
            $app['session']->set('user', array('userId' => $user->getId()));
            return $app->redirect('/');
        }

        $response = new Response();
        $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', 'site_login'));
        $response->setStatusCode(401, 'Please sign in.');
        return $response;
    }
<commit_msg>Set user object in session<commit_after><?php

namespace Koddi\Controller;

use Silex\Application;
use Symfony\Component\HttpFoundation\Response;

class AuthController
{
    public function getLogin(Application $app)
    {
        $username = $app['request']->server->get('PHP_AUTH_USER', false);
        $password = $app['request']->server->get('PHP_AUTH_PW');

        $user = $app['userService']->checkCredentials($username, $password);

        if ($user) {
            $app['session']->set('user', $user);
            return $app->redirect('/');
        }

        $response = new Response();
        $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', 'site_login'));
        $response->setStatusCode(401, 'Please sign in.');
        return $response;
    }

{'fraction_non_alphanumeric': 0.17687934301958308, 'fraction_numerical': 0.003790271636133923, 'mean_word_length': 3.281081081081081, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2472878', 'n_tokens_mistral': 466, 'n_tokens_neox': 463, 'n_words': 85}