summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mastoapi.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 1c0ad87..fbb6843 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -147,6 +147,11 @@ int token_del(const char *id)
147 147
148const char *login_page = "" 148const char *login_page = ""
149"<!DOCTYPE html>\n" 149"<!DOCTYPE html>\n"
150"<html>\n"
151"<head>\n"
152"<title>%s OAuth - Snac2</title>\n"
153"<style>:root {color-scheme: light dark}</style>\n"
154"</head>\n"
150"<body><h1>%s OAuth identify</h1>\n" 155"<body><h1>%s OAuth identify</h1>\n"
151"<div style=\"background-color: red; color: white\">%s</div>\n" 156"<div style=\"background-color: red; color: white\">%s</div>\n"
152"<form method=\"post\" action=\"https:/" "/%s/%s\">\n" 157"<form method=\"post\" action=\"https:/" "/%s/%s\">\n"
@@ -156,7 +161,7 @@ const char *login_page = ""
156"<input type=\"hidden\" name=\"cid\" value=\"%s\">\n" 161"<input type=\"hidden\" name=\"cid\" value=\"%s\">\n"
157"<input type=\"hidden\" name=\"state\" value=\"%s\">\n" 162"<input type=\"hidden\" name=\"state\" value=\"%s\">\n"
158"<input type=\"submit\" value=\"OK\">\n" 163"<input type=\"submit\" value=\"OK\">\n"
159"</form><p>%s</p></body>\n" 164"</form><p>%s</p></body></html>\n"
160""; 165"";
161 166
162int oauth_get_handler(const xs_dict *req, const char *q_path, 167int oauth_get_handler(const xs_dict *req, const char *q_path,
@@ -190,7 +195,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
190 if (xs_is_null(state)) 195 if (xs_is_null(state))
191 state = ""; 196 state = "";
192 197
193 *body = xs_fmt(login_page, host, "", host, "oauth/x-snac-login", 198 *body = xs_fmt(login_page, host, host, "", host, "oauth/x-snac-login",
194 ruri, cid, state, USER_AGENT); 199 ruri, cid, state, USER_AGENT);
195 *ctype = "text/html"; 200 *ctype = "text/html";
196 status = 200; 201 status = 200;
@@ -207,7 +212,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
207 if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ 212 if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/
208 const char *host = xs_dict_get(srv_config, "host"); 213 const char *host = xs_dict_get(srv_config, "host");
209 214
210 *body = xs_fmt(login_page, host, "", host, "oauth/x-snac-get-token", 215 *body = xs_fmt(login_page, host, host, "", host, "oauth/x-snac-get-token",
211 "", "", "", USER_AGENT); 216 "", "", "", USER_AGENT);
212 *ctype = "text/html"; 217 *ctype = "text/html";
213 status = 200; 218 status = 200;
@@ -257,7 +262,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
257 const char *host = xs_dict_get(srv_config, "host"); 262 const char *host = xs_dict_get(srv_config, "host");
258 263
259 /* by default, generate another login form with an error */ 264 /* by default, generate another login form with an error */
260 *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, "oauth/x-snac-login", 265 *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", host, "oauth/x-snac-login",
261 redir, cid, state, USER_AGENT); 266 redir, cid, state, USER_AGENT);
262 *ctype = "text/html"; 267 *ctype = "text/html";
263 status = 200; 268 status = 200;
@@ -426,7 +431,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
426 const char *host = xs_dict_get(srv_config, "host"); 431 const char *host = xs_dict_get(srv_config, "host");
427 432
428 /* by default, generate another login form with an error */ 433 /* by default, generate another login form with an error */
429 *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, "oauth/x-snac-get-token", 434 *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", host, "oauth/x-snac-get-token",
430 "", "", "", USER_AGENT); 435 "", "", "", USER_AGENT);
431 *ctype = "text/html"; 436 *ctype = "text/html";
432 status = 200; 437 status = 200;