Example #1
0
 public function actionUser()
 {
     $model = new InstallUserForm();
     $error = false;
     $success = 'n';
     $model->fullname = "Developer";
     $model->username = "******";
     if (isset($_POST['InstallUserForm'])) {
         $model->attributes = $_POST['InstallUserForm'];
         if ($model->validate()) {
             $user = User::model()->find();
             if (!is_null($user)) {
                 $user->username = $model->username;
                 $user->password = Helper::hash($model->password);
                 $user->is_deleted = 0;
                 $user->update(['username', 'password', 'is_deleted']);
             } else {
                 ## TODO: throw error: failed to update username & password
             }
             Installer::createIndexFile("running");
             $this->redirect(['/install/default/finish']);
         }
     }
     $this->renderForm('InstallUserForm', $model, ['error' => $error, 'success' => $success]);
 }
Example #2
0
 public function actionUser()
 {
     $model = new InstallUserForm();
     $error = false;
     $success = 'n';
     $model->fullname = "Developer";
     $model->username = "******";
     if (isset($_POST['InstallUserForm'])) {
         $model->attributes = $_POST['InstallUserForm'];
         if ($model->validate()) {
             ActiveRecord::execute("\n                set foreign_key_checks = 0;\n                UPDATE `p_user` SET\n                    `id` = '1',\n                    `email` = '-',\n                    `username` = '{$model->username}',\n                    `password` = '" . Helper::hash($model->password) . "',\n                    `last_login` = '2015-02-26 07:06:32',\n                    `is_deleted` = '0'\n                WHERE `id` = '1';\n                ");
             Installer::createIndexFile("running");
             $this->redirect(['/install/default/finish']);
         }
     }
     $this->renderForm('InstallUserForm', $model, ['error' => $error, 'success' => $success]);
 }