summaryrefslogtreecommitdiffstats
path: root/apps/remoteStorage/auth.php
diff options
context:
space:
mode:
authorMichiel de Jong <michiel@unhosted.org>2012-05-09 15:17:01 +0200
committerMichiel de Jong <michiel@unhosted.org>2012-05-09 15:28:30 +0200
commit7d090a45d21f8a662d8562abedf4d8dba70a70e0 (patch)
treeff1e8d95ece13eb2e70134bd1af83317abc00b1e /apps/remoteStorage/auth.php
parent63cc1ccacd1908292854dd8ca35d6fb5009ddbbb (diff)
downloadnextcloud-server-7d090a45d21f8a662d8562abedf4d8dba70a70e0.tar.gz
nextcloud-server-7d090a45d21f8a662d8562abedf4d8dba70a70e0.zip
attempt at reusing access tokens
Diffstat (limited to 'apps/remoteStorage/auth.php')
-rwxr-xr-xapps/remoteStorage/auth.php40
1 files changed, 21 insertions, 19 deletions
diff --git a/apps/remoteStorage/auth.php b/apps/remoteStorage/auth.php
index a5cbd6aca02..ac8c2423291 100755
--- a/apps/remoteStorage/auth.php
+++ b/apps/remoteStorage/auth.php
@@ -62,6 +62,8 @@ if(count($pathParts) == 2 && $pathParts[0] == '') {
//TODO: check if this can be faked by editing the cookie in firebug!
$token=OC_remoteStorage::createCategories($appUrl, $categories);
header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=bearer');
+ } else if($existingToken = OC_remoteStorage::getTokenFor($appUrl, $categories)) {
+ header('Location: '.$_GET['redirect_uri'].'#access_token='.$existingToken.'&token_type=bearer');
} else {
?>
<!DOCTYPE html>
@@ -82,25 +84,25 @@ if(count($pathParts) == 2 && $pathParts[0] == '') {
</header>
<section id="main">
<div id="oauth">
- <h2><img src="../remoteStorage-big.png" alt="remoteStorage" /></h2>
- <p><strong><?php $appUrlParts = explode('/', $_GET['redirect_uri']); echo htmlentities($appUrlParts[2]); ?></strong>
- requests read &amp; write access to your
- <?php
- $categories = explode(',', htmlentities($_GET['scope']));
- if(!count($categories)) {
- echo htmlentities($_GET['scope']);
- } else {
- echo '<em>'.$categories[0].'</em>';
- if(count($categories)==2) {
- echo ' and <em>'.$categories[1].'</em>';
- } else if(count($categories)>2) {
- for($i=1; $i<count($categories)-1; $i++) {
- echo ', <em>'.$categories[$i].'</em>';
- }
- echo ', and <em>'.$categories[$i].'</em>';
- }
- }
- ?>.
+ <h2><img src="../remoteStorage-big.png" alt="remoteStorage" /></h2>
+ <p><strong><?php $appUrlParts = explode('/', $_GET['redirect_uri']); echo htmlentities($appUrlParts[2]); ?></strong>
+ requests read &amp; write access to your
+ <?php
+ $categories = explode(',', htmlentities($_GET['scope']));
+ if(!count($categories)) {
+ echo htmlentities($_GET['scope']);
+ } else {
+ echo '<em>'.$categories[0].'</em>';
+ if(count($categories)==2) {
+ echo ' and <em>'.$categories[1].'</em>';
+ } else if(count($categories)>2) {
+ for($i=1; $i<count($categories)-1; $i++) {
+ echo ', <em>'.$categories[$i].'</em>';
+ }
+ echo ', and <em>'.$categories[$i].'</em>';
+ }
+ }
+ ?>.
</p>
<form accept-charset="UTF-8" method="post">
<input id="allow-auth" name="allow" type="submit" value="Allow" />