summaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/lib/Service
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2016-12-13 10:47:48 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2016-12-19 11:59:47 +0100
commit93003120461648140ee244b345cfcb6690071faa (patch)
tree6f6abee9824742b4c45517137bf6f3881d761c26 /apps/twofactor_backupcodes/lib/Service
parent7ae9442f3d4cdb2a98ae680979d6fcb33350cc02 (diff)
downloadnextcloud-server-93003120461648140ee244b345cfcb6690071faa.tar.gz
nextcloud-server-93003120461648140ee244b345cfcb6690071faa.zip
push activity when backup codes are generated
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/twofactor_backupcodes/lib/Service')
-rw-r--r--apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
index bb10081bb54..d7bcfe01475 100644
--- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
+++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
@@ -24,6 +24,7 @@ namespace OCA\TwoFactorBackupCodes\Service;
use OCA\TwoFactorBackupCodes\Db\BackupCode;
use OCA\TwoFactorBackupCodes\Db\BackupCodeMapper;
+use OCP\Activity\IManager;
use OCP\IUser;
use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
@@ -39,10 +40,14 @@ class BackupCodeStorage {
/** @var ISecureRandom */
private $random;
- public function __construct(BackupCodeMapper $mapper, ISecureRandom $random, IHasher $hasher) {
+ /** @var IManager */
+ private $activityManager;
+
+ public function __construct(BackupCodeMapper $mapper, ISecureRandom $random, IHasher $hasher, IManager $activityManager) {
$this->mapper = $mapper;
$this->hasher = $hasher;
$this->random = $random;
+ $this->activityManager = $activityManager;
}
/**
@@ -68,10 +73,28 @@ class BackupCodeStorage {
array_push($result, $code);
}
+ $this->publishEvent($user, 'codes_generated');
+
return $result;
}
/**
+ * Push an event the user's activity stream
+ *
+ * @param IUser $user
+ * @param string $event
+ */
+ private function publishEvent(IUser $user, $event) {
+ $activity = $this->activityManager->generateEvent();
+ $activity->setApp('twofactor_backupcodes')
+ ->setType('twofactor')
+ ->setAuthor($user->getUID())
+ ->setAffectedUser($user->getUID());
+ $activity->setSubject($event);
+ $this->activityManager->publish($activity);
+ }
+
+ /**
* @param IUser $user
* @return bool
*/