mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-29 12:41:03 +00:00
Dash updates
This commit is contained in:
1 parent
0c296a17f8
commit
aee72b3fbf
8 files changed
+541
-188
No files matched your search
@@ -162,6 +162,17 @@ static struct mg_field_set set_graph2 = {
|
||||
"graph2", fields_graph2, read_graph2, NULL, 0, 0, NULL,
|
||||
};
|
||||
|
||||
static int authenticate(const char *user, const char *pass) {
|
||||
int level = 0; // Authentication failure
|
||||
if (strcmp(pass, "admin") == 0) {
|
||||
level = 7; // Administrator
|
||||
} else if (strcmp(pass, "user") == 0) {
|
||||
level = 3; // Ordinary dude
|
||||
}
|
||||
(void) user;
|
||||
return level;
|
||||
}
|
||||
|
||||
void mg_dash_init(struct mg_mgr *mgr) {
|
||||
static struct mg_dash dash; // Important: keep it static!
|
||||
|
||||
@@ -176,6 +187,9 @@ void mg_dash_init(struct mg_mgr *mgr) {
|
||||
mg_dash_file_add(mg_str("device-config.json"), 1234);
|
||||
mg_dash_file_add(mg_str("device-log-2026-04-25.txt"), 1327854);
|
||||
|
||||
// Require authentication
|
||||
dash.authenticate = authenticate;
|
||||
|
||||
mg_http_listen(mgr, MG_HTTP_ADDR, mg_dash_ev_handler, &dash);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user