Commit f6f21c20 authored by Daniel Carden's avatar Daniel Carden

Add new file

parent 75bdbb8c
Pipeline #525 failed with stage
<?php
function doAuth($output,$dbADO) {
// include our OAuth2 Server object
include_once('oauth2-server.php');
$request = OAuth2\Request::createFromGlobals();
$response = new OAuth2\Response();
// validate the authorize request
if (!$server->validateAuthorizeRequest($request, $response)) {
$response->send();
die('<script>top.location="index.php?section=login"</script>');
}
if ($_SESSION['userLoggedIn']==true && !isset($_POST['authorisation_form'])) {
// display an authorization form
$form = '<form name="authform" id="authform" method="post" >
<label>Do You Authorize '.$_GET['client_id'].'?</label><br />
<input type="hidden" id="authorisation_form" name="authorisation_form" value="yes">
<input type="submit" name="authorized" value="yes">
<input type="submit" name="authorized" value="no">
</form>';
$output->setBody($form);
$output->setTitle(APPLICATION_NAME);
$output->output();
} elseif ($_SESSION['userLoggedIn']==true && $_POST['authorized'] === 'yes'){
// print the authorization code if the user has authorized your client
$is_authorized = ($_POST['authorized'] === 'yes');
$server->handleAuthorizeRequest($request, $response, $is_authorized, $_SESSION['userID']);
$response->send();
} else {
die('<script>top.location="index.php?section=login"</script>');
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment