+23
-2
@@ -49,6 +49,7 @@ pre.raw-line { background: var(--bs-tertiary-bg); padding: .75rem; border-radius
|
||||
<div class="card-body p-4 text-center">
|
||||
<i class="bi bi-shield-lock" style="font-size:3rem;display:block;margin-bottom:1rem"></i>
|
||||
<h5>Sign in required</h5>
|
||||
<div id="authErrorBox" class="alert alert-danger d-none" role="alert"></div>
|
||||
<p class="text-secondary mb-4">Authenticate with your Jakach account to access the system.</p>
|
||||
<a id="loginBtn" class="btn btn-primary btn-lg w-100" href="#">
|
||||
<i class="bi bi-box-arrow-in-right me-2"></i>Log in using Jakach Login
|
||||
@@ -367,16 +368,36 @@ async function checkAuth() {
|
||||
initApp();
|
||||
return true;
|
||||
}
|
||||
} catch (e) {}
|
||||
if (res.error) {
|
||||
showLogin(res.error);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
try {
|
||||
const err = JSON.parse(e.message);
|
||||
showLogin(err.error);
|
||||
} catch {
|
||||
showLogin();
|
||||
}
|
||||
}
|
||||
showLogin();
|
||||
return false;
|
||||
}
|
||||
|
||||
function showLogin() {
|
||||
function showLogin(errorMsg) {
|
||||
document.getElementById('appLogin').style.display = '';
|
||||
document.getElementById('appMain').style.display = 'none';
|
||||
const loginUrl = window.location.origin + '/oauth.php?redirect=' + encodeURIComponent(window.location.href);
|
||||
document.getElementById('loginBtn').href = 'https://auth.jakach.ch/?send_to=' + encodeURIComponent(loginUrl);
|
||||
const errorBox = document.getElementById('authErrorBox');
|
||||
if (errorMsg) {
|
||||
errorBox.textContent = errorMsg;
|
||||
errorBox.classList.remove('d-none');
|
||||
document.getElementById('loginBtn').textContent = 'Try again';
|
||||
} else {
|
||||
errorBox.classList.add('d-none');
|
||||
document.getElementById('loginBtn').innerHTML = '<i class="bi bi-box-arrow-in-right me-2"></i>Log in using Jakach Login';
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
|
||||
Reference in New Issue
Block a user