checkauth logic & login dialog

This commit is contained in:
STEINNI
2025-09-03 22:39:04 +00:00
parent 3fc9b0731e
commit e315a3061e
5 changed files with 86 additions and 28 deletions
+26 -15
View File
@@ -89,23 +89,34 @@ class myUser extends app.LoadedClasses.User {
*
* @param {*} callBack
*/
checkAuthenticated(callBack){
let headers = {};
if(app.config.userLib.authForwardDomain) {
let url = new URL(document.location.href);
headers = { 'x-requested-path': url.pathname };
}
async checkAuthenticated(callBack){
document.getElementById('startbtn').addEventListener('click', async () => {
document.getElementById('startbtn').disabled = true
const response = await fetch(app.config.userLib.checkauthEndpoint+'?'+crypto.randomUUID())
let payload = null
if(response.ok) { payload = await response.json() }
if(!payload) {
console.error('No valid response from checkauth !?')
document.getElementById('startbtn').disabled = false
} else if(!payload.authenticated){
console.log('==>login',app)
document.getElementById('login-dialog').classList.add('show')
} else {
console.log('authenticated!')
}
document.getElementById('startbtn').addEventListener('click', () => {
console.log('====> click')
callBack()
})
this.identity = {
uuid: 'nike',
email: 'info@nicsys.eu'
};
this.roles = ['admin']
this.isAuthenticated = true
// console.log('====> click')
// callBack()
// })
// this.identity = {
// uuid: 'nike',
// email: 'info@nicsys.eu'
// };
// this.roles = ['admin']
// this.isAuthenticated = true
//setTimeout(callBack, 20000);
/*