|
@ -74,7 +74,7 @@ $app->get('/auth/start', function() use($app) { |
|
|
$req = $app->request(); |
|
|
$req = $app->request(); |
|
|
|
|
|
|
|
|
$params = $req->params(); |
|
|
$params = $req->params(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// the "me" parameter is user input, and may be in a couple of different forms:
|
|
|
// the "me" parameter is user input, and may be in a couple of different forms:
|
|
|
// aaronparecki.com http://aaronparecki.com http://aaronparecki.com/
|
|
|
// aaronparecki.com http://aaronparecki.com http://aaronparecki.com/
|
|
|
// Normlize the value now (move this into a function in IndieAuth\Client later)
|
|
|
// Normlize the value now (move this into a function in IndieAuth\Client later)
|
|
@ -88,6 +88,10 @@ $app->get('/auth/start', function() use($app) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(k($params, 'redirect')) { |
|
|
|
|
|
$_SESSION['redirect_after_login'] = $params['redirect']; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$authorizationEndpoint = IndieAuth\Client::discoverAuthorizationEndpoint($me); |
|
|
$authorizationEndpoint = IndieAuth\Client::discoverAuthorizationEndpoint($me); |
|
|
$tokenEndpoint = IndieAuth\Client::discoverTokenEndpoint($me); |
|
|
$tokenEndpoint = IndieAuth\Client::discoverTokenEndpoint($me); |
|
|
$micropubEndpoint = IndieAuth\Client::discoverMicropubEndpoint($me); |
|
|
$micropubEndpoint = IndieAuth\Client::discoverMicropubEndpoint($me); |
|
@ -244,7 +248,13 @@ $app->get('/auth/callback', function() use($app) { |
|
|
unset($_SESSION['auth_state']); |
|
|
unset($_SESSION['auth_state']); |
|
|
|
|
|
|
|
|
if($redirectToDashboardImmediately) { |
|
|
if($redirectToDashboardImmediately) { |
|
|
$app->redirect('/new', 301); |
|
|
|
|
|
|
|
|
if(k($_SESSION, 'redirect_after_login')) { |
|
|
|
|
|
$dest = $_SESSION['redirect_after_login']; |
|
|
|
|
|
unset($_SESSION['redirect_after_login']); |
|
|
|
|
|
$app->redirect($dest, 301); |
|
|
|
|
|
} else { |
|
|
|
|
|
$app->redirect('/new', 301); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
$html = render('auth_callback', array( |
|
|
$html = render('auth_callback', array( |
|
|
'title' => 'Sign In', |
|
|
'title' => 'Sign In', |
|
@ -254,7 +264,8 @@ $app->get('/auth/callback', function() use($app) { |
|
|
'tokenEndpoint' => $tokenEndpoint, |
|
|
'tokenEndpoint' => $tokenEndpoint, |
|
|
'auth' => $token['auth'], |
|
|
'auth' => $token['auth'], |
|
|
'response' => $token['response'], |
|
|
'response' => $token['response'], |
|
|
'curl_error' => (array_key_exists('error', $token) ? $token['error'] : false) |
|
|
|
|
|
|
|
|
'curl_error' => (array_key_exists('error', $token) ? $token['error'] : false), |
|
|
|
|
|
'destination' => (k($_SESSION, 'redirect_after_login') ?: '/new') |
|
|
)); |
|
|
)); |
|
|
$app->response()->body($html); |
|
|
$app->response()->body($html); |
|
|
} |
|
|
} |
|
|