commit 2f3ed55
default
·
2023-06-24 06:29:29 +0000 UTC
parent 3da32bd
The WWW-Authenticate real also includes the user.
M
html.c
+10,
-3
1@@ -1565,8 +1565,10 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2 }
3 else
4 if (strcmp(p_path, "admin") == 0) { /** private timeline **/
5- if (!login(&snac, req))
6+ if (!login(&snac, req)) {
7+ *body = xs_dup(uid);
8 status = 401;
9+ }
10 else {
11 if (cache && history_mtime(&snac, "timeline.html_") > timeline_mtime(&snac)) {
12 snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
13@@ -1593,8 +1595,10 @@ int html_get_handler(const xs_dict *req, const char *q_path,
14 }
15 else
16 if (strcmp(p_path, "people") == 0) { /** the list of people **/
17- if (!login(&snac, req))
18+ if (!login(&snac, req)) {
19+ *body = xs_dup(uid);
20 status = 401;
21+ }
22 else {
23 *body = html_people(&snac);
24 *b_size = strlen(*body);
25@@ -1603,8 +1607,10 @@ int html_get_handler(const xs_dict *req, const char *q_path,
26 }
27 else
28 if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/
29- if (!login(&snac, req))
30+ if (!login(&snac, req)) {
31+ *body = xs_dup(uid);
32 status = 401;
33+ }
34 else {
35 *body = html_notifications(&snac);
36 *b_size = strlen(*body);
37@@ -1758,6 +1764,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
38 /* all posts must be authenticated */
39 if (!login(&snac, req)) {
40 user_free(&snac);
41+ *body = xs_dup(uid);
42 return 401;
43 }
44
M
httpd.c
+3,
-1
1@@ -251,7 +251,9 @@ void httpd_connection(FILE *f)
2 headers = xs_dict_append(headers, "location", body);
3
4 if (status == 401) {
5- xs *www_auth = xs_fmt("Basic realm=\"%s snac login\"", xs_dict_get(srv_config, "host"));
6+ xs *www_auth = xs_fmt("Basic realm=\"@%s@%s snac login\"",
7+ body, xs_dict_get(srv_config, "host"));
8+
9 headers = xs_dict_append(headers, "WWW-Authenticate", www_auth);
10 }
11