<?php
/**
 * bentbox_connect.php
 * Step 1: send the creator to BentBox to approve your platform.
 *
 * Link your "Connect BentBox" button here. It stores a one-time CSRF state in
 * an encrypted cookie and redirects to the BentBox consent screen. If the
 * creator isn't signed in to BentBox, BentBox asks them to sign in first and
 * then shows the consent screen. BentBox then sends them to bentbox_callback.php.
 */
require_once __DIR__ . '/bentbox_config.php';

// Already connected? Go straight to the upload page.
if (bb_is_connected() && !isset($_GET['reconnect'])) {
    header('Location: bentbox_upload.php');
    exit;
}

header('Cache-Control: no-store');
header('Location: ' . bb_authorize_url());
exit;
