diff --git a/lib/private/Authentication/Token/DefaultToken.php b/lib/private/Authentication/Token/DefaultToken.php index 85ea0dc4cd..b1095d0a23 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 0000000000..ede075a21c --- /dev/null +++ b/lib/private/Authentication/Token/INamedToken.php @@ -0,0 +1,34 @@ +. + * + */ + +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 b6f5514670..b3d87fea7e 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 b1016fb4a3..5b2788bb0c 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); }