summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@owncloud.com>2016-05-18 12:03:22 +0200
committerChristoph Wurst <christoph@owncloud.com>2016-05-23 09:11:12 +0200
commit12431aa3997154aaea4eec11c2dd65f9e5dbe179 (patch)
tree8395c270b144401f53e5ed048f94a28002410e3d /lib
parent357d342467b9200f190376a2bd224fa7b803b45a (diff)
downloadnextcloud-server-12431aa3997154aaea4eec11c2dd65f9e5dbe179.tar.gz
nextcloud-server-12431aa3997154aaea4eec11c2dd65f9e5dbe179.zip
list user's auth tokens on the personal settings page
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Authentication/Token/DefaultToken.php12
-rw-r--r--lib/private/Server.php3
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/private/Authentication/Token/DefaultToken.php b/lib/private/Authentication/Token/DefaultToken.php
index 08451a46151..ca4c723fba3 100644
--- a/lib/private/Authentication/Token/DefaultToken.php
+++ b/lib/private/Authentication/Token/DefaultToken.php
@@ -22,6 +22,7 @@
namespace OC\Authentication\Token;
+use JsonSerializable;
use OCP\AppFramework\Db\Entity;
/**
@@ -38,7 +39,7 @@ use OCP\AppFramework\Db\Entity;
* @method void setLastActivity(int $lastActivity)
* @method int getLastActivity()
*/
-class DefaultToken extends Entity implements IToken {
+class DefaultToken extends Entity implements IToken, JsonSerializable {
/**
* @var string user UID
@@ -87,4 +88,13 @@ class DefaultToken extends Entity implements IToken {
return parent::getPassword();
}
+ public function jsonSerialize() {
+ return [
+ 'id' => $this->id,
+ 'name' => $this->name,
+ 'lastActivity' => $this->lastActivity,
+ 'type' => $this->type,
+ ];
+ }
+
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 0b7b8f9e403..ea0c436d84b 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -223,6 +223,7 @@ class Server extends ServerContainer implements IServerContainer {
$timeFactory = new TimeFactory();
return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
});
+ $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
$this->registerService('UserSession', function (Server $c) {
$manager = $c->getUserManager();
$session = new \OC\Session\Memory('');
@@ -230,7 +231,7 @@ class Server extends ServerContainer implements IServerContainer {
// Token providers might require a working database. This code
// might however be called when ownCloud is not yet setup.
if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
- $defaultTokenProvider = $c->query('OC\Authentication\Token\DefaultTokenProvider');
+ $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
} else {
$defaultTokenProvider = null;
}