Skip to content

Commit 47873b2

Browse files
committed
version 1
1 parent e421354 commit 47873b2

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

.htaccess

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RewriteEngine On
2+
RewriteCond %{REQUEST_FILENAME} !-f
3+
RewriteRule ^([^/]+)/$ $1.php
4+
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
5+
RewriteCond %{REQUEST_FILENAME} !-f
6+
RewriteCond %{REQUEST_FILENAME} !-d
7+
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
8+
RewriteRule (.*)$ /$1/ [R=301,L]

callback/orcid.php

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<?PHP
2+
session_start();
3+
?>
14
<!DOCTYPE html>
25
<html lang="en">
36
<head>
@@ -16,21 +19,18 @@
1619
'client_secret' => '***REMOVED_ORCID_CLIENT_SECRET***',
1720
'grant_type' => 'authorization_code',
1821
'code' => $_GET["code"],
19-
'redirect_uri' => 'https://accounts.assembl.science/callback/orcid.php'
22+
'redirect_uri' => 'https://accounts.assembl.science/callback/orcid/'
2023
)));
2124
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
2225
$response = curl_exec($ch);
2326
curl_close($ch);
2427
if ($response !== false) {
2528
if (isset($_SESSION["signin_return_key_as_json"]) && $_SESSION["signin_return_key_as_json"] == true) {
26-
?>
27-
<h2>You are now signed in to Assembl.</h2>
28-
<p>This part hasn't been finished yet. We're working on it as we speak!</p>
29-
<br /><br />
30-
<p><i><small><?PHP print_r($_POST); ?></small></i></p>
31-
<?PHP
29+
ob_end_clean();
30+
echo $response;
3231
}
3332
else {
33+
$_SESSION["orcid_data"] = json_decode($response, true);
3434
?>
3535
<h2>You are now signed in to Assembl.</h2>
3636
<p>This part hasn't been finished yet. <a href="https://assembl.science">Return to the home page</a></p>
@@ -46,12 +46,20 @@
4646
<?PHP
4747
}
4848
}
49+
else if (isset($_GET["error"])) {
50+
?>
51+
<h2>Something went wrong</h2>
52+
<p>Could not sign in with ORCID. Please try again later.</p>
53+
<br /><br />
54+
<p><i><small><?PHP echo $_GET["error_description"]; ?></small></i></p>
55+
<?PHP
56+
}
4957
else {
5058
?>
5159
<h2>Something went wrong</h2>
5260
<p>Could not sign in with ORCID. Please try again later.</p>
5361
<br /><br />
54-
<p><i><small>GET parameter 'code' is not set</small></i></p>
62+
<p><i><small>GET parameter 'code' but also 'error' is not set <?PHP print_r($_POST); ?></small></i></p>
5563
<?PHP
5664
}
5765
?>

index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?PHP
2-
header("Location: signin.php");
2+
header("Location: https://accounts.assembl.science/signin/");
33
exit();
44
?>

signin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
var h = 600;
2828
var left = (window.innerWidth/2)-(w/2);
2929
var top = (window.innerHeight/2)-(h/2);
30-
oAuthWindow = window.open("https://orcid.org/oauth/authorize?client_id=***REMOVED_ORCID_CLIENT_ID***&response_type=code&scope=/read-limited&redirect_uri=https://accounts.assembl.science/callback/orcid.php", "_blank", "toolbar=no, scrollbars=yes, width="+w+", height="+h+", top="+top+", left="+left);
30+
oAuthWindow = window.open("https://orcid.org/oauth/authorize?client_id=***REMOVED_ORCID_CLIENT_ID***&response_type=code&scope=/authenticate&redirect_uri=https://accounts.assembl.science/callback/orcid/", "_blank", "toolbar=no, scrollbars=yes, width="+w+", height="+h+", top="+top+", left="+left);
3131
});
3232
</script>
3333
</body>

0 commit comments

Comments
 (0)