oidc: Handle login without redirect from backend and set some default

ttls
This commit is contained in:
Johannes Zellner
2023-03-14 10:47:01 +01:00
parent 5e4e292b4d
commit aae4acc419
2 changed files with 28 additions and 8 deletions
+4 -2
View File
@@ -68,15 +68,17 @@ document.getElementById('loginForm').addEventListener('submit', function (event)
};
fetch(apiUrl, {
method: 'POST'
method: 'POST',
body: JSON.stringify(body),
headers: { 'Content-type': 'application/json; charset=UTF-8' }
}).then(function (response) {
if (response.ok) return response.json();
return Promise.reject(response);
}).then(function (data) {
console.log('login success', data);
if (data.redirectTo) window.location.href = data.redirectTo;
else console.log('login success but missing redirectTo in data:', data);
}).catch(function (error) {
if (error.status === 401) document.getElementById('inputPassword').value = ''
console.warn('Something went wrong.', error);
});
});