migration = $factory; } public function getMigrations(Updater $updater) { $userColumn = $this->migration->db->addColumn('user', 'twofactor_secret', "VARCHAR(40) NOT NULL DEFAULT ''"); $backupCode = $this->migration->db->createTable('twofactor_recovery_code', array( 'idrecoverycode' => 'BIGINT UNSIGNED NOT NULL AUTO_INCREMENT', 'login' => 'VARCHAR(100) NOT NULL', 'recovery_code' => 'VARCHAR(40) NOT NULL', ), array('idrecoverycode')); $twoFactorAuth = $this->migration->plugin->activate('TwoFactorAuth'); $googleAuth = $this->migration->plugin->deactivate('GoogleAuthenticator'); return array($userColumn, $backupCode, $twoFactorAuth, $googleAuth); } public function doUpdate(Updater $updater) { $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); if (Plugin\Manager::getInstance()->isPluginActivated('GoogleAuthenticator')) { foreach (Option::getLike('GoogleAuthentication.%') as $name => $value) { $value = @unserialize($value); if (!empty($value['isActive']) && !empty($value['secret'])) { $login = str_replace('GoogleAuthentication.', '', $name); $table = Common::prefixTable('user'); Db::query("UPDATE $table SET twofactor_secret = ? where login = ?", array($value['secret'], $login)); } } } } }