implemented custom loggin
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -8,8 +8,13 @@
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<nav></nav>
|
||||
<h1>Authorization!</h1>
|
||||
Not implemented, yet!
|
||||
<nav></nav>
|
||||
<div id="content" style="display: none">
|
||||
<h1>Authorization</h1>
|
||||
Confirmation required: are you shure you want to grant access to <span id="name">some client</span>?
|
||||
<button type="button" onclick="grantAutorization()">Yes</button>
|
||||
<button type="button" onclick="denyAutorization()">No</button>
|
||||
</div>
|
||||
<div id="error" class="error" style="display: none"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +1,46 @@
|
||||
var params = new URLSearchParams(window.location.search)
|
||||
var json = Object.fromEntries(params);
|
||||
|
||||
function showConfirmationDialog(name){
|
||||
get('name').innerHTML = name;
|
||||
show('content');
|
||||
}
|
||||
|
||||
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);
|
||||
console.log("handleResponse(ok) ←",json);
|
||||
if (!json.confirmed){
|
||||
showConfirmationDialog(json.name);
|
||||
} else {
|
||||
redirect(json.redirect_uri+'?code='+json.code+'&state='+json.state+'&scope=openid');
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
var json = await response.json();
|
||||
console.log("handleResponse(error) ←",json);
|
||||
get('error').innerHTML = "Error: <br/>"+JSON.stringify(json);
|
||||
show('error');
|
||||
}
|
||||
}
|
||||
|
||||
fetch(api+"/authorize",{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(json),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(handleResponse);
|
||||
function grantAutorization(){
|
||||
json.confirmed = true;
|
||||
backendAutorization();
|
||||
}
|
||||
|
||||
function denyAutorization(){
|
||||
redirect(params.get('redirect_uri')+"?error=access denied");
|
||||
}
|
||||
|
||||
function backendAutorization(){
|
||||
fetch(api+"/authorize",{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(json),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(handleResponse);
|
||||
}
|
||||
|
||||
backendAutorization();
|
||||
@@ -20,7 +20,6 @@ function getValue(id){
|
||||
}
|
||||
|
||||
function hide(id){
|
||||
console.log('hide('+id+')');
|
||||
get(id).style.display = 'none';
|
||||
}
|
||||
|
||||
@@ -38,6 +37,5 @@ function setValue(id,newVal){
|
||||
}
|
||||
|
||||
function show(id){
|
||||
console.log('show('+id+')');
|
||||
get(id).style.display = '';
|
||||
}
|
||||
@@ -29,5 +29,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<a href="https://umbrella.srsoftware.de/user/login">Umbrella</a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user