Change 2FA activities to more generic security activities

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2017-05-16 09:37:21 +02:00 committed by Roeland Jago Douma
parent 879e11e7d1
commit 0928b5f621
No known key found for this signature in database
GPG Key ID: F941078878347C0C
6 changed files with 24 additions and 24 deletions

View File

@ -18,14 +18,7 @@
</dependencies> </dependencies>
<activity> <activity>
<filters>
<filter>OCA\TwoFactorBackupCodes\Activity\GenericFilter</filter>
</filters>
<settings>
<setting>OCA\TwoFactorBackupCodes\Activity\GenericSetting</setting>
</settings>
<providers> <providers>
<provider>OCA\TwoFactorBackupCodes\Activity\GenericProvider</provider>
<provider>OCA\TwoFactorBackupCodes\Activity\Provider</provider> <provider>OCA\TwoFactorBackupCodes\Activity\Provider</provider>
</providers> </providers>
</activity> </activity>

View File

@ -23,6 +23,7 @@
namespace OC\Authentication\TwoFactorAuth; namespace OC\Authentication\TwoFactorAuth;
use BadMethodCallException;
use Exception; use Exception;
use OC; use OC;
use OC\App\AppManager; use OC\App\AppManager;
@ -218,16 +219,16 @@ class Manager {
*/ */
private function publishEvent(IUser $user, $event, array $params) { private function publishEvent(IUser $user, $event, array $params) {
$activity = $this->activityManager->generateEvent(); $activity = $this->activityManager->generateEvent();
$activity->setApp('twofactor_generic') $activity->setApp('core')
->setType('twofactor') ->setType('security')
->setAuthor($user->getUID()) ->setAuthor($user->getUID())
->setAffectedUser($user->getUID()) ->setAffectedUser($user->getUID())
->setSubject($event, $params); ->setSubject($event, $params);
try { try {
$this->activityManager->publish($activity); $this->activityManager->publish($activity);
} catch (Exception $e) { } catch (BadMethodCallException $e) {
$this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']); $this->logger->warning('could not publish backup code creation activity', ['app' => 'core']);
$this->logger->logException($e, ['app' => 'twofactor_backupcodes']); $this->logger->logException($e, ['app' => 'core']);
} }
} }

View File

@ -20,13 +20,13 @@
* *
*/ */
namespace OCA\TwoFactorBackupCodes\Activity; namespace OC\Settings\Activity;
use OCP\Activity\IFilter; use OCP\Activity\IFilter;
use OCP\IL10N; use OCP\IL10N;
use OCP\IURLGenerator; use OCP\IURLGenerator;
class GenericFilter implements IFilter { class SecurityFilter implements IFilter {
/** @var IURLGenerator */ /** @var IURLGenerator */
private $urlGenerator; private $urlGenerator;
@ -44,7 +44,7 @@ class GenericFilter implements IFilter {
} }
public function filterTypes(array $types) { public function filterTypes(array $types) {
return array_intersect(['twofactor'], $types); return array_intersect(['security'], $types);
} }
public function getIcon() { public function getIcon() {
@ -52,11 +52,11 @@ class GenericFilter implements IFilter {
} }
public function getIdentifier() { public function getIdentifier() {
return 'twofactor'; return 'security';
} }
public function getName() { public function getName() {
return $this->l10n->t('Two-factor authentication'); return $this->l10n->t('Security');
} }
public function getPriority() { public function getPriority() {

View File

@ -20,7 +20,7 @@
* *
*/ */
namespace OCA\TwoFactorBackupCodes\Activity; namespace OC\Settings\Activity;
use InvalidArgumentException; use InvalidArgumentException;
use OCP\Activity\IEvent; use OCP\Activity\IEvent;
@ -29,7 +29,7 @@ use OCP\ILogger;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\L10N\IFactory as L10nFactory; use OCP\L10N\IFactory as L10nFactory;
class GenericProvider implements IProvider { class SecurityProvider implements IProvider {
/** @var L10nFactory */ /** @var L10nFactory */
private $l10n; private $l10n;
@ -47,7 +47,7 @@ class GenericProvider implements IProvider {
} }
public function parse($language, IEvent $event, IEvent $previousEvent = null) { public function parse($language, IEvent $event, IEvent $previousEvent = null) {
if ($event->getType() !== 'twofactor') { if ($event->getType() !== 'security') {
throw new InvalidArgumentException(); throw new InvalidArgumentException();
} }

View File

@ -20,12 +20,12 @@
* *
*/ */
namespace OCA\TwoFactorBackupCodes\Activity; namespace OC\Settings\Activity;
use OCP\Activity\ISetting; use OCP\Activity\ISetting;
use OCP\IL10N; use OCP\IL10N;
class GenericSetting implements ISetting { class SecuritySetting implements ISetting {
/** @var IL10N */ /** @var IL10N */
private $l10n; private $l10n;
@ -43,11 +43,11 @@ class GenericSetting implements ISetting {
} }
public function getIdentifier() { public function getIdentifier() {
return 'twofactor'; return 'security';
} }
public function getName() { public function getName() {
return $this->l10n->t('Two-factor authentication'); return $this->l10n->t('Security');
} }
public function getPriority() { public function getPriority() {

View File

@ -34,6 +34,9 @@ use OC\AppFramework\Utility\TimeFactory;
use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IProvider;
use OC\Server; use OC\Server;
use OC\Settings\Activity\Provider; use OC\Settings\Activity\Provider;
use OC\Settings\Activity\SecurityFilter;
use OC\Settings\Activity\SecurityProvider;
use OC\Settings\Activity\SecuritySetting;
use OC\Settings\Activity\Setting; use OC\Settings\Activity\Setting;
use OC\Settings\Mailer\NewUserMailHelper; use OC\Settings\Mailer\NewUserMailHelper;
use OC\Settings\Middleware\SubadminMiddleware; use OC\Settings\Middleware\SubadminMiddleware;
@ -114,6 +117,9 @@ class Application extends App {
$activityManager = $this->getContainer()->getServer()->getActivityManager(); $activityManager = $this->getContainer()->getServer()->getActivityManager();
$activityManager->registerSetting(Setting::class); // FIXME move to info.xml $activityManager->registerSetting(Setting::class); // FIXME move to info.xml
$activityManager->registerProvider(Provider::class); // FIXME move to info.xml $activityManager->registerProvider(Provider::class); // FIXME move to info.xml
$activityManager->registerFilter(SecurityFilter::class); // FIXME move to info.xml
$activityManager->registerSetting(SecuritySetting::class); // FIXME move to info.xml
$activityManager->registerProvider(SecurityProvider::class); // FIXME move to info.xml
Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword');
Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo');