summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Authentication/Token/DefaultToken.php16
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenMapperTest.php1
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/private/Authentication/Token/DefaultToken.php b/lib/private/Authentication/Token/DefaultToken.php
index ecfb1a44f2e..127430ea6cb 100644
--- a/lib/private/Authentication/Token/DefaultToken.php
+++ b/lib/private/Authentication/Token/DefaultToken.php
@@ -92,6 +92,12 @@ class DefaultToken extends Entity implements IToken {
*/
protected $scope;
+ public function __construct() {
+ $this->addType('type', 'int');
+ $this->addType('lastActivity', 'int');
+ $this->addType('lastCheck', 'int');
+ }
+
public function getId() {
return $this->id;
}
@@ -122,8 +128,8 @@ class DefaultToken extends Entity implements IToken {
return [
'id' => $this->id,
'name' => $this->name,
- 'lastActivity' => (int)$this->lastActivity,
- 'type' => (int)$this->type,
+ 'lastActivity' => $this->lastActivity,
+ 'type' => $this->type,
'scope' => $this->getScopeAsArray()
];
}
@@ -161,10 +167,10 @@ class DefaultToken extends Entity implements IToken {
}
public function setScope($scope) {
- if (is_string($scope)) {
- parent::setScope($scope);
- } else {
+ if (is_array($scope)) {
parent::setScope(json_encode($scope));
+ } else {
+ parent::setScope((string)$scope);
}
}
}
diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
index 418a4d14f62..7520b3c9f65 100644
--- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
@@ -122,7 +122,6 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testGetToken() {
- $token = '1504445f1524fc801035448a95681a9378ba2e83930c814546c56e5d6ebde221198792fd900c88ed5ead0555780dad1ebce3370d7e154941cd5de87eb419899b';
$token = new DefaultToken();
$token->setUid('user2');
$token->setLoginName('User2');