aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Authentication/Token/DefaultToken.php7
-rw-r--r--lib/private/Authentication/Token/INamedToken.php34
-rw-r--r--lib/private/Authentication/Token/PublicKeyToken.php7
-rw-r--r--settings/Controller/AuthSettingsController.php6
4 files changed, 47 insertions, 7 deletions
diff --git a/lib/private/Authentication/Token/DefaultToken.php b/lib/private/Authentication/Token/DefaultToken.php
index 85ea0dc4cdd..b1095d0a23b 100644
--- a/lib/private/Authentication/Token/DefaultToken.php
+++ b/lib/private/Authentication/Token/DefaultToken.php
@@ -30,7 +30,6 @@ use OCP\AppFramework\Db\Entity;
* @method void setId(int $id)
* @method void setUid(string $uid);
* @method void setLoginName(string $loginname)
- * @method void setName(string $name)
* @method string getToken()
* @method void setType(int $type)
* @method int getType()
@@ -39,7 +38,7 @@ use OCP\AppFramework\Db\Entity;
* @method int getLastActivity()
* @method void setVersion(int $version)
*/
-class DefaultToken extends Entity implements IToken {
+class DefaultToken extends Entity implements INamedToken {
const VERSION = 1;
@@ -179,6 +178,10 @@ class DefaultToken extends Entity implements IToken {
return parent::getName();
}
+ public function setName(string $name): void {
+ parent::setName($name);
+ }
+
public function getRemember(): int {
return parent::getRemember();
}
diff --git a/lib/private/Authentication/Token/INamedToken.php b/lib/private/Authentication/Token/INamedToken.php
new file mode 100644
index 00000000000..ede075a21c0
--- /dev/null
+++ b/lib/private/Authentication/Token/INamedToken.php
@@ -0,0 +1,34 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019, Daniel Kesselberg (mail@danielkesselberg.de)
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Authentication\Token;
+
+
+interface INamedToken extends IToken {
+ /**
+ * Set token name
+ *
+ * @param string $name
+ * @return void
+ */
+ public function setName(string $name): void;
+} \ No newline at end of file
diff --git a/lib/private/Authentication/Token/PublicKeyToken.php b/lib/private/Authentication/Token/PublicKeyToken.php
index b6f55146707..b3d87fea7ea 100644
--- a/lib/private/Authentication/Token/PublicKeyToken.php
+++ b/lib/private/Authentication/Token/PublicKeyToken.php
@@ -31,7 +31,6 @@ use OCP\AppFramework\Db\Entity;
* @method void setId(int $id)
* @method void setUid(string $uid);
* @method void setLoginName(string $loginname)
- * @method void setName(string $name)
* @method string getToken()
* @method void setType(int $type)
* @method int getType()
@@ -45,7 +44,7 @@ use OCP\AppFramework\Db\Entity;
* @method void setVersion(int $version)
* @method bool getPasswordInvalid()
*/
-class PublicKeyToken extends Entity implements IToken {
+class PublicKeyToken extends Entity implements INamedToken {
const VERSION = 2;
@@ -197,6 +196,10 @@ class PublicKeyToken extends Entity implements IToken {
return parent::getName();
}
+ public function setName(string $name): void {
+ parent::setName($name);
+ }
+
public function getRemember(): int {
return parent::getRemember();
}
diff --git a/settings/Controller/AuthSettingsController.php b/settings/Controller/AuthSettingsController.php
index b1016fb4a39..5b2788bb0c1 100644
--- a/settings/Controller/AuthSettingsController.php
+++ b/settings/Controller/AuthSettingsController.php
@@ -31,7 +31,7 @@ use BadMethodCallException;
use OC\AppFramework\Http;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
-use OC\Authentication\Token\DefaultToken;
+use OC\Authentication\Token\INamedToken;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OC\Settings\Activity\Provider;
@@ -115,7 +115,7 @@ class AuthSettingsController extends Controller {
return array_map(function (IToken $token) use ($sessionToken) {
$data = $token->jsonSerialize();
$data['canDelete'] = true;
- $data['canRename'] = $token instanceof DefaultToken || $token instanceof PublicKeyToken;
+ $data['canRename'] = $token instanceof INamedToken;
if ($sessionToken->getId() === $token->getId()) {
$data['canDelete'] = false;
$data['canRename'] = false;
@@ -231,7 +231,7 @@ class AuthSettingsController extends Controller {
]);
- if ($token instanceof DefaultToken || $token instanceof PublicKeyToken) {
+ if ($token instanceof INamedToken) {
$token->setName($name);
}