<commit_before><?php
namespace app\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\helpers\ArrayHelper;
use yii\filters\VerbFilter;
use yii\data\Pagination;
use yii\helpers\Url;
use yii\web\UploadedFile;

use app\models\SignUpForm;
use app\models\Userlogin;
use app\models\Userinfo;
use app\models\LoginForm;
use app\models\CreateAdForm;
use app\models\UploadForm;
use app\models\Productcategory;
use app\models\Adsinfo;
use app\models\ChangePasswordForm;


class UserController extends Controller
{
   /*
    Sign up action
   */
   public function actionSignup()
    {
        $model = new SignUpForm();

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
           
            // valid data received in $model is inserted into the userlogin table
            $userLoginObject = new Userlogin();
            $userLoginObject->username = $model->email;
            $userLoginObject->password = password_hash($model->password, PASSWORD_DEFAULT);
            $userLoginObject->save();
         
            if($userLoginObject->save(false)) {
                //Insert data to userinfo table
                $userInfoObject = new Userinfo();
                $userInfoObject->contactAddress = $model->contactAddress;
                $userInfoObject->name = $model->name;
                $userInfoObject->mobile = $model->mobile;
                $userInfoObject->role = 0;
                $userInfoObject->userId = $userLoginObject->id;
                $userInfoObject->save();

                if($userInfoObject->save()) {
                    //logging in with the new account details
                    $loginObject = new LoginForm();
                    $loginObject->username = $userLoginObject->username;
                    $loginObject->password = $model->password;
                    if($loginObject->login()) {
                         if(!Yii::$app->user->isGuest) {
                            return $this->render('account', [
                                'model' => $userInfoObject,
                            ]);   
                        }
                    }
                }
            }
                            
        } else {
            // the sign up page is reloaded
            return $this->render('signup', ['model' => $model]);
        }
    }
    
    /*
    Edit Profile action
   */
    public function actionAccount() {
       
        $userId = Yii::$app->user->id; // the logged in user's id<commit_msg>Fixed the redirection issue during signup<commit_after><?php
namespace app\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\helpers\ArrayHelper;
use yii\filters\VerbFilter;
use yii\data\Pagination;
use yii\helpers\Url;
use yii\web\UploadedFile;

use app\models\SignUpForm;
use app\models\Userlogin;
use app\models\Userinfo;
use app\models\LoginForm;
use app\models\CreateAdForm;
use app\models\UploadForm;
use app\models\Productcategory;
use app\models\Adsinfo;
use app\models\ChangePasswordForm;


class UserController extends Controller
{
   /*
    Sign up action
   */
   public function actionSignup()
    {
        $model = new SignUpForm();

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
           
            // valid data received in $model is inserted into the userlogin table
            $userLoginObject = new Userlogin();
            $userLoginObject->username = $model->email;
            $userLoginObject->password = password_hash($model->password, PASSWORD_DEFAULT);
            $userLoginObject->save();
         
            if($userLoginObject->save(false)) {
                //Insert data to userinfo table
                $userInfoObject = new Userinfo();
                $userInfoObject->contactAddress = $model->contactAddress;
                $userInfoObject->name = $model->name;
                $userInfoObject->mobile = $model->mobile;
                $userInfoObject->role = 0;
                $userInfoObject->userId = $userLoginObject->id;
                $userInfoObject->save();

                if($userInfoObject->save()) {
                    //logging in with the new account details
                    $loginObject = new LoginForm();
                    $loginObject->username = $userLoginObject->username;
                    $loginObject->password = $<PASSWORD>;
                    if($loginObject->login()) {
                         if(!Yii::$app->user->isGuest) {

                            return Yii::$app->response->redirect(Url::to(['user/account',
                                   'model' => $userInfoObject,
                            ])); 
                        }
                    }
                }
            }
                            
        } else {
            // the sign up page is reloaded
            return $this->render('signup', ['model' => $model]);
        }
    }
    
    /*
    Edit Profile action
   */
    public function actionAccount() {
       
        $userId = Yii::$app->user->id; // the logged in user's id
{'fraction_non_alphanumeric': 0.11856075501376327, 'fraction_numerical': 0.00039323633503735744, 'mean_word_length': 1.7174145299145298, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6862594', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1321, 'n_words': 280}