ukasiu / oauthorize

Light phpBB MOD to enable login with internal OAuth
0 stars 1 forks source link

Not redirecting, not remembering #11

Open kruczjak opened 9 years ago

kruczjak commented 9 years ago
switch ($provider) {
  // Internal authentication is several steps
  // Get temporary token using Internal application credentials
  // Then reload the page catching an oauth_verifier parameter from Internal
  // Get permament token using temporary token
  // Then reload the page 
  case 'internal':
    $internalService = $serviceFactory->createService('internal', $credentials, $storage, array());
    if (!empty($_GET['code'])) {
      // This was a callback request from google, get the token
      $internalService->requestAccessToken($_GET['code']);
      // Send a request with it
      $result = json_decode($internalService->request('https://accounts.iiet.pl/appapi/v1/students/me'), true);
      $oauth_profile = array(
        'id' => $result['user_id'],
      );
    } else {
      if (isset($_GET['remember'])) {
        setcookie('remember', $_GET['remember'], time() + 3600, '/');
      }
      setcookie('redirect_to', $_SERVER['HTTP_REFERER'], time()+3600, '/');
      $url = $internalService->getAuthorizationUri();
      header('Location: ' . $url);
    }
    break;
  default:
    $message = $user->lang['OAUTH_UNKOWN_PROVIDER'];
    meta_refresh(3, $phpbb_root_path);
    trigger_error($message);
    break;
}
kruczjak commented 9 years ago

I think this part doesn't work, I'll debug it :P

kruczjak commented 9 years ago

Yep, $_GET['remember'] and $_SERVER['HTTP_REFERER'] are empty -_-

kruczjak commented 9 years ago

Fixed in #12 .