divided Backend into several controllers

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-07-25 01:26:23 +02:00
parent 493c642992
commit 0c1baee8e0
19 changed files with 410 additions and 291 deletions

View File

@@ -34,7 +34,7 @@ function denyAutorization(){
}
function backendAutorization(){
fetch(api+"/authorize",{
fetch(client_controller+"/authorize",{
method: 'POST',
body: JSON.stringify(json),
headers: {

View File

@@ -20,7 +20,7 @@ function handleRemove(response){
function remove(clientId){
var message = document.getElementById('message').innerHTML;
if (confirm(message.replace("{}",clientId))) {
fetch(api+"/client",{
fetch(client_controller+"/delete",{
method: 'DELETE',
body : JSON.stringify({ client_id : clientId })
}).then(handleRemove);
@@ -31,4 +31,4 @@ function edit(clientId){
redirect("edit_client.html?id="+clientId);
}
fetch(api+"/clients",{method:'POST'}).then(handleClients);
fetch(client_controller+"/list",{method:'POST'}).then(handleClients);

View File

@@ -1,4 +1,6 @@
var api = "/api";
var client_controller = "/api/client"
var user_controller = "/api/user"
var web = "/web";
const UNAUTHORIZED = 401;

View File

@@ -17,7 +17,7 @@ function doRedirect(){
function tryLogin(){
var username = getValue('username');
var password = getValue('password');
fetch(api+"/login",{
fetch(user_controller+"/login",{
method: 'POST',
headers: {
Accept: 'application/json',

View File

@@ -2,4 +2,4 @@ function handleLogout(response){
if (response.ok) document.body.innerHTML += 'success';
redirect('index.html')
}
fetch(api+"/logout").then(handleLogout)
fetch(user_controller+"/logout").then(handleLogout)

View File

@@ -6,7 +6,7 @@ function addClient(){
secret : getValue('client-secret'),
redirect_uris : getValue('redirect-urls').split("\n")
};
fetch(api+'/add/client',{
fetch(client_controller+'/add',{
method : 'POST',
headers : {
'Content-Type': 'application/json'

View File

@@ -31,7 +31,7 @@ function update(){
email : getValue('email'),
uuid : getValue('uuid')
}
fetch(api+'/update/user',{
fetch(user_controller+'/update',{
method : 'POST',
headers : {
'Content-Type': 'application/json'
@@ -68,7 +68,7 @@ function updatePass(){
newpass : [getValue('newpass1'),getValue('newpass2')],
uuid : getValue('uuid')
}
fetch(api+'/update/password',{
fetch(user_controller+'/password',{
method : 'POST',
headers : {
'Content-Type': 'application/json'

View File

@@ -24,4 +24,4 @@ async function handleNavigation(response){
}
}
fetch(api+"/user",{method:'POST'}).then(handleUser);
fetch(user_controller+"/",{method:'POST'}).then(handleUser);