<commit_before><?php

namespace SlimAPI\Controllers;

use SlimAPI\Factory;
use SlimController\SlimController;

class AuthController extends SlimController {

    private function renderUnauthorized () {
        $this->render(401, array(
            "error" => true,
            "msg" => "Unauthorized access"
        ));
    }

    public function loginAction() {
        // You can use the authentication data stored in $auth variable
        $auth = $this->app->container["settings"]["auth"];

        $request = $this->app->request;
        if ( $request->isFormData() ) {
            $username = $request->post("username");
            $password = $request->post("password");
        }
        if ( strtolower($request->getContentType()) == "application/json" ) {
            $json = json_decode($request->getBody(), true);
            if ( $json !== NULL ) {
                $username = $json["username"];
                $password = $json["password"];
            }
        }
        if ( empty($username) || empty($password) ) {
            $this->renderUnauthorized();
            return;
        }

        /**
         * @var \PDO
         */
        $pdo = $this->app->getPDOConnection();
        $user = $pdo->select()
            ->from("extui_user")
            ->where("username", "=", $username)
            ->where("password", "=", <PASSWORD>1($password))
            ->where("status", ">", 0)
            ->execute()
            ->fetch();

        if ( empty($user) ) {
            $this->renderUnauthorized();
            return;
        }

        $pdo->update(array("lastlogin_time"=>gmdate("Y-m-d H:i:s")))
            ->table("extui_user")
            ->where("id", "=", $user["id"])
            ->execute();

        $this->app->setAuthData(Factory::createAuthData($user));

        $this->render(200);
    }

}<commit_msg>Update AuthController.php<commit_after><?php

namespace SlimAPI\Controllers;

use SlimAPI\Factory;
use SlimController\SlimController;

class AuthController extends SlimController {

    private function renderUnauthorized () {
        $this->render(401, array(
            "error" => true,
            "msg" => "Unauthorized access"
        ));
    }

    public function loginAction() {
        // You can use the authentication data stored in $auth variable
        $auth = $this->app->container["settings"]["auth"];

        $request = $this->app->request;
        if ( $request->isFormData() ) {
            $username = $request->post("username");
            $password = $request->post("password");
        }
        if ( strtolower($request->getContentType()) == "application/json" ) {
            $json = json_decode($request->getBody(), true);
            if ( $json !== NULL ) {
                $username = $json["username"];
                $password = $json["password"];
            }
        }
        if ( empty($username) || empty($password) ) {
            $this->renderUnauthorized();
            return;
        }

        /**
         * @var \PDO
         */
        $pdo = $this->app->getPDOConnection();
        $user = $pdo->select()
            ->from("extui_user")
            ->where("username", "=", $username)
            ->where("password", "=", <PASSWORD>($password))
            ->where("status", ">", 0)
            ->execute()
            ->fetch();

        if ( empty($user) ) {
            $this->renderUnauthorized();
            return;
        }

        $pdo->update(array("lastlogin_time"=>gmdate("Y-m-d H:i:s")))
            ->table("tbl_user")
            ->where("id", "=", $user["id"])
            ->execute();

        $this->app->setAuthData(Factory::createAuthData($user));

        $this->render(200);
    }

}
{'fraction_non_alphanumeric': 0.1757085020242915, 'fraction_numerical': 0.004048582995951417, 'mean_word_length': 1.8573631457208943, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 69, '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': '6593254', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1033, 'n_words': 179}