<commit_before><?php
namespace yii2mod\user\actions;


use yii\base\Action;
use yii\web\Response;
use yii\widgets\ActiveForm;
use yii2mod\user\models\LoginForm;

/**
 * Class LoginAction
 * @package yii2mod\user\actions
 */
class LoginAction extends Action
{
    /**
     * @var string
     */
    public $view = '@vendor/yii2mod/yii2-user/views/login';

    /**
     * @return string
     */
    public function run()
    {
        if (!\Yii::$app->user->isGuest) {
            return $this->controller->goHome();
        }
        $model = new LoginForm();
        $load = $model->load(\Yii::$app->request->post());

        if (\Yii::$app->request->isAjax) {
            \Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }

        if ($load && $model->login()) {
            $model->getUser()->updateLastLogin();
            return $this->controller->goBack();
        } else {
            return $this->controller->render($this->view, [
                'model' => $model,
            ]);
        }
    }

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

namespace yii2mod\user\actions;

use yii\base\Action;
use yii\web\Response;
use yii\widgets\ActiveForm;

/**
 * Class LoginAction
 * @package yii2mod\user\actions
 */
class LoginAction extends Action
{
    /**
     * @var string
     */
    public $view = '@vendor/yii2mod/yii2-user/views/login';

    /**
     * @var string Login Form className
     */
    public $modelClass = 'yii2mod\user\models\LoginForm';

    /**
     * @return string
     */
    public function run()
    {
        if (!\Yii::$app->user->isGuest) {
            return $this->controller->goHome();
        }
        $model = new $this->modelClass;
        $load = $model->load(\Yii::$app->request->post());

        if (\Yii::$app->request->isAjax) {
            \Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }

        if ($load && $model->login()) {
            $model->getUser()->updateLastLogin();
            return $this->controller->goBack();
        } else {
            return $this->controller->render($this->view, [
                'model' => $model,
            ]);
        }
    }

}

{'fraction_non_alphanumeric': 0.17181978798586572, 'fraction_numerical': 0.00441696113074205, 'mean_word_length': 2.02, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '2062767', 'n_tokens_mistral': 707, 'n_tokens_neox': 701, 'n_words': 117}