parent
0b28014597
commit
d9b0013329
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$payload_fil = '/tmp/oauth-'.$ID;
|
||||
if (!file_exists($payload_fil)) {
|
||||
header('Location: /signup'); die;
|
||||
}
|
||||
|
||||
$payload = json_decode(file_get_contents($payload_fil));
|
||||
var_dump($payload);
|
||||
var_dump($code);
|
||||
die;
|
@ -0,0 +1,39 @@
|
||||
<script>
|
||||
const http = {
|
||||
request: function(method, path, payload, callbk) {
|
||||
payload = payload || null;
|
||||
callbk = callbk || null;
|
||||
const oReq = new XMLHttpRequest();
|
||||
oReq.addEventListener("load", function() { if (callbk) callbk(this.responseText) });
|
||||
oReq.open(method, path);
|
||||
oReq.setRequestHeader('Content-Type', 'application/json');
|
||||
oReq.send(payload);
|
||||
},
|
||||
get: function(path, payload, callbk) {
|
||||
return http.request('GET', path, payload, callbk);
|
||||
},
|
||||
post: function(path, payload, callbk) {
|
||||
return http.request('POST', path, payload, callbk);
|
||||
}
|
||||
};
|
||||
|
||||
const API = {
|
||||
mastodon: {
|
||||
registerInstance: function(instance) {
|
||||
http.get('/api/signup/mastodon/get_client.php?instance='+encodeURIComponent(instance), {}, function(data)
|
||||
{
|
||||
data = JSON.parse(data);
|
||||
if (data.status === 'err') {
|
||||
alert(data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
const res = data.message;
|
||||
const oauthUrl = res.instance+'/oauth/authorize?client_id='+encodeURIComponent(res.result.client_id)+'&redirect_uri='+encodeURIComponent(res.result.redirect_uri+'?id='+res.id)+'&response_type='+encodeURIComponent(res.response_type)+'&scope='+encodeURIComponent(res.scope);
|
||||
localStorage['auth_data'] = JSON.stringify(res);
|
||||
document.location.href = oauthUrl;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in new issue