Initial commit: SenSu Alpha 0.2.0
- 13-service async plugin framework - Textual TUI with CLI fallback - Plugin hot-reload + permission system - Web management panel (aiohttp) - Bridge-based inter-module communication - 10 regression tests Fixes applied: - PBKDF2-SHA256 auth (was plain SHA256) - Auth bypass removed (was allow-all on fail) - Bare excepts replaced with logged errors - CatFramework/DreamSu -> SenSu naming unified - ServiceManager: health checks + startup_order - Env var credentials (SENSU_ADMIN_PASSWORD etc)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
const BASE = '/panel';
|
||||
|
||||
export const api = {
|
||||
get: async (url) => {
|
||||
const res = await fetch(`${BASE}${url}`, { credentials: 'include' });
|
||||
return res.json();
|
||||
},
|
||||
post: async (url, data) => {
|
||||
const res = await fetch(`${BASE}${url}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'include',
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
};
|
||||
|
||||
export async function initAuth() {
|
||||
// 登录逻辑绑定到 DOM
|
||||
const loginForm = document.querySelector('#login-form');
|
||||
if(loginForm) {
|
||||
loginForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const u = document.getElementById('username').value;
|
||||
const p = document.getElementById('password').value;
|
||||
const res = await api.post('/api/login', { username: u, password: p });
|
||||
if (res.success) location.reload(); // 登录成功刷新
|
||||
});
|
||||
}
|
||||
return await api.get('/api/auth/status');
|
||||
}
|
||||
Reference in New Issue
Block a user