remove the saved redirect when it's being used, always accept email scope
authorRobert Kaiser <kairo@kairo.at>
Fri, 28 Oct 2016 18:56:13 +0000 (20:56 +0200)
committerRobert Kaiser <kairo@kairo.at>
Fri, 28 Oct 2016 18:56:13 +0000 (20:56 +0200)
authorize.php
index.php

index 2a7e0a5a12b4cdb0f37cc265cfc0cb8ed33377ab..4275254873b22fffd0dfaad35dd9490eff2050c4 100644 (file)
@@ -55,8 +55,8 @@ if (!count($errors)) {
       exit();
     }
 
-    // Display an authorization form.
-    if (empty($_POST)) {
+    // Display an authorization form (unless the scope is email, which we always grant in this system).
+    if (empty($_POST) && (@$request->query['scope'] != 'email')) {
       $para = $body->appendElement('p', sprintf(_('Hi %s!'), $user['email']));
       $para->setAttribute('class', 'userwelcome');
 
@@ -71,7 +71,7 @@ if (!count($errors)) {
     }
     else {
       // Handle authorize request, forwarding code in GET parameters if the user has authorized your client.
-      $is_authorized = ($_POST['authorized'] === 'yes');
+      $is_authorized = (($_POST['authorized'] === 'yes') || ($request->query['scope'] == 'email'));
       $server->handleAuthorizeRequest($request, $response, $is_authorized);
       /* For testing only
       if ($is_authorized) {
index e01c7d157b47706dff8f6b793f122fa3c9a7d83c..ee03d8b034c115a935d0913eab33b04edd138733 100644 (file)
--- a/index.php
+++ b/index.php
@@ -70,6 +70,11 @@ if (!count($errors)) {
           // If the session has a redirect set, make sure it's performed.
           if (strlen(@$session['saved_redirect'])) {
             header('Location: '.$utils->getDomainBaseURL().$session['saved_redirect']);
+            // Remove redirect.
+            $result = $db->prepare('UPDATE `auth_sessions` SET `saved_redirect` = :redir WHERE `id` = :sessid;');
+            if (!$result->execute(array(':redir' => '', ':sessid' => $session['id']))) {
+              $utils->log('redir_save_failure', 'session: '.$session['id'].', redirect: (empty)');
+            }
           }
           // If the session has a user set, create a new one - otherwise take existing session entry.
           if (intval($session['user'])) {