summaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-07-03 09:44:37 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2019-07-09 13:39:27 +0200
commit1c261675ad3da9804bd9a8c88326103eb2f56bd3 (patch)
treebb8dfba33103e10ca51eef1519dc25c46ec55cd3 /lib/private/Authentication
parent22de685f546474890ff43bc7d68754afe9fbd6f1 (diff)
downloadnextcloud-server-1c261675ad3da9804bd9a8c88326103eb2f56bd3.tar.gz
nextcloud-server-1c261675ad3da9804bd9a8c88326103eb2f56bd3.zip
Refactor: move remote wipe token logic to RW service
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Authentication')
-rw-r--r--lib/private/Authentication/Token/IWipeableToken.php7
-rw-r--r--lib/private/Authentication/Token/RemoteWipe.php14
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/Authentication/Token/IWipeableToken.php b/lib/private/Authentication/Token/IWipeableToken.php
index 8d4d3a60781..f0777bf4a24 100644
--- a/lib/private/Authentication/Token/IWipeableToken.php
+++ b/lib/private/Authentication/Token/IWipeableToken.php
@@ -24,6 +24,11 @@ declare(strict_types=1);
namespace OC\Authentication\Token;
-interface IWipeableToken {
+interface IWipeableToken extends IToken {
+
+ /**
+ * Mark the token for remote wipe
+ */
public function wipe(): void;
+
}
diff --git a/lib/private/Authentication/Token/RemoteWipe.php b/lib/private/Authentication/Token/RemoteWipe.php
index 5534ff1cba1..38f1f439e8e 100644
--- a/lib/private/Authentication/Token/RemoteWipe.php
+++ b/lib/private/Authentication/Token/RemoteWipe.php
@@ -35,6 +35,7 @@ use OCP\Activity\IManager as IActivityManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
+use OCP\IUser;
use OCP\Notification\IManager as INotificationManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -57,6 +58,19 @@ class RemoteWipe {
$this->logger = $logger;
}
+ public function markTokenForWipe(int $id): bool {
+ $token = $this->tokenProvider->getTokenById($id);
+
+ if (!($token instanceof IWipeableToken)) {
+ return false;
+ }
+
+ $token->wipe();
+ $this->tokenProvider->updateToken($token);
+
+ return true;
+ }
+
/**
* @param string $token
*