working on authorization flow
This commit is contained in:
@@ -16,8 +16,6 @@ public class Forward extends PathHandler {
|
||||
@Override
|
||||
public boolean doGet(String path, HttpExchange ex) throws IOException {
|
||||
System.out.printf("Forwarding (%d) %s to %s…\n", CODE, path, toPath);
|
||||
ex.getResponseHeaders().add("Location", toPath);
|
||||
ex.sendResponseHeaders(CODE, 0);
|
||||
return true;
|
||||
return sendRedirect(ex,toPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
<script src="common.js"></script>
|
||||
<script src="user.js"></script>
|
||||
<script src="authorization.js"></script>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<nav></nav>
|
||||
<h1>Authorization!</h1>
|
||||
Not implemented, yet!
|
||||
</body>
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
var params = new URLSearchParams(window.location.search)
|
||||
var json = Object.fromEntries(params);
|
||||
|
||||
async function handleResponse(response){
|
||||
if (response.ok){
|
||||
var json = await response.json();
|
||||
console.log(json);
|
||||
redirect(json.redirect_uri+'?code='+json.code+'&state='+json.state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fetch(api+"/authorize",{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(json),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
}).then(handleResponse);
|
||||
@@ -1,7 +1,7 @@
|
||||
var user = null;
|
||||
async function handleUser(response){
|
||||
if (response.status == UNAUTHORIZED) {
|
||||
redirect('login.html?return_to='+encodeURI(window.location.href));
|
||||
redirect('login.html?return_to='+encodeURIComponent(window.location.href));
|
||||
return;
|
||||
}
|
||||
if (response.ok){
|
||||
|
||||
Reference in New Issue
Block a user