implemented cookies, implemented local file delivery option (--base /path/to/static/content), refactoring static files
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -2,10 +2,7 @@
|
||||
<head>
|
||||
<title>Light OIDC</title>
|
||||
<script src="config.js"></script>
|
||||
<script src="lightoidc.js"></script>
|
||||
<script>
|
||||
checkUser();
|
||||
</script>
|
||||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome!</h1>
|
||||
|
||||
7
de.srsoftware.oidc.web/src/main/resources/en/index.js
Normal file
7
de.srsoftware.oidc.web/src/main/resources/en/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const UNAUTHORIZED = 401;
|
||||
|
||||
function handleUser(response){
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
fetch(api+"/user").then(handleUser);
|
||||
@@ -1,43 +0,0 @@
|
||||
const UNAUTHORIZED = 401;
|
||||
|
||||
function handleCheckUser(response){
|
||||
console.log(window.location.href);
|
||||
if (response.status == UNAUTHORIZED){
|
||||
window.location.href = "login.html";
|
||||
return;
|
||||
}
|
||||
}
|
||||
function checkUser(){
|
||||
fetch(api+"/user")
|
||||
.then(handleCheckUser)
|
||||
.catch((err) => console.log(err));
|
||||
}
|
||||
|
||||
function handleLogin(response){
|
||||
if (response.status == 401){
|
||||
loadError("login-failed");
|
||||
return;
|
||||
}
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
function loadError(page){
|
||||
fetch(web+"/"+page+".txt").then(resp => resp.text()).then(showError);
|
||||
}
|
||||
|
||||
function showError(content){
|
||||
document.getElementById("error").innerHTML = content;
|
||||
}
|
||||
|
||||
function tryLogin(){
|
||||
document.getElementById("error").innerHTML = "";
|
||||
var data = Object.fromEntries(new FormData(document.getElementById('login')));
|
||||
fetch(api+"/login",{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}).then(handleLogin);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<head>
|
||||
<title>Light OIDC</title>
|
||||
<script src="config.js"></script>
|
||||
<script src="lightoidc.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Login</h1>
|
||||
|
||||
Reference in New Issue
Block a user