public function actionAuto()
 {
     $this->stdout("Install:\n\n", Console::FG_YELLOW);
     \humhub\modules\installer\libs\InitialData::bootstrap();
     Yii::$app->settings->set('name', "HumHub Test");
     Yii::$app->settings->set('mailer.systemEmailName', "*****@*****.**");
     Yii::$app->settings->set('mailer.systemEmailName', "*****@*****.**");
     Yii::$app->settings->set('secret', \humhub\libs\UUID::v4());
     $user = new User();
     //$user->group_id = 1;
     $user->username = "******";
     $user->email = '*****@*****.**';
     $user->status = User::STATUS_ENABLED;
     $user->language = '';
     $user->last_activity_email = new \yii\db\Expression('NOW()');
     if (!$user->save()) {
         throw new \yii\base\Exception("Could not save user");
     }
     $user->profile->title = "System Administration";
     $user->profile->firstname = "John";
     $user->profile->lastname = "Doe";
     $user->profile->save();
     $password = new Password();
     $password->user_id = $user->id;
     $password->setPassword('test');
     $password->save();
     // Assign to system admin group
     Group::getAdminGroup()->addUser($user);
     return self::EXIT_CODE_NORMAL;
 }
 /**
  * Resets users password based on given token
  */
 public function actionReset()
 {
     $user = User::findOne(array('guid' => Yii::$app->request->get('guid')));
     if ($user === null || !$this->checkPasswordResetToken($user, Yii::$app->request->get('token'))) {
         throw new HttpException('500', 'It looks like you clicked on an invalid password reset link. Please try again.');
     }
     $model = new Password();
     $model->scenario = 'registration';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         Yii::$app->getModule('user')->settings->contentContainer($user)->delete('passwordRecoveryToken');
         $model->user_id = $user->id;
         $model->setPassword($model->newPassword);
         $model->save();
         return $this->render('reset_success');
     }
     return $this->render('reset', array('model' => $model));
 }
 public function actionSetDefaultPass()
 {
     if (isset($_GET['user_ids'])) {
         $user_ids = explode(",", $_GET['user_ids']);
         foreach ($user_ids as $user_id) {
             $userPasswordModel = new Password();
             $userPasswordModel->user_id = $user_id;
             $userPasswordModel->setPassword("password");
             if ($userPasswordModel->save()) {
                 echo "Saved... <br />";
             }
         }
     } else {
         echo "<p>?user_ids=user_id,user_id to reset the password of users to 'password'</p>";
     }
 }