summaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication/Token/DefaultTokenProvider.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@owncloud.com>2016-04-27 09:38:30 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-05-11 13:36:46 +0200
commitfdc2cd755477220c027e026aa70594af87427bed (patch)
tree74fccc3156ed16b44e48189616a8019012f07703 /lib/private/Authentication/Token/DefaultTokenProvider.php
parent8d4850218740b74faae5af637d1b1c2b3dee3c41 (diff)
downloadnextcloud-server-fdc2cd755477220c027e026aa70594af87427bed.tar.gz
nextcloud-server-fdc2cd755477220c027e026aa70594af87427bed.zip
Add token auth for OCS APIs
Diffstat (limited to 'lib/private/Authentication/Token/DefaultTokenProvider.php')
-rw-r--r--lib/private/Authentication/Token/DefaultTokenProvider.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php
index a4e44f3c5d2..97567e53cd0 100644
--- a/lib/private/Authentication/Token/DefaultTokenProvider.php
+++ b/lib/private/Authentication/Token/DefaultTokenProvider.php
@@ -83,7 +83,11 @@ class DefaultTokenProvider implements IProvider {
*
* @param DefaultToken $token
*/
- public function updateToken(DefaultToken $token) {
+ public function updateToken(IToken $token) {
+ if (!($token instanceof DefaultToken)) {
+ throw new InvalidTokenException();
+ }
+ /** @var DefaultToken $token */
$token->setLastActivity(time());
$this->mapper->update($token);
@@ -130,14 +134,14 @@ class DefaultTokenProvider implements IProvider {
/**
* @param string $token
* @throws InvalidTokenException
- * @return string user UID
+ * @return IToken user UID
*/
public function validateToken($token) {
$this->logger->debug('validating default token <' . $token . '>');
try {
$dbToken = $this->mapper->getToken($this->hashToken($token));
$this->logger->debug('valid token for ' . $dbToken->getUid());
- return $dbToken->getUid();
+ return $dbToken;
} catch (DoesNotExistException $ex) {
$this->logger->warning('invalid token');
throw new InvalidTokenException();