summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mastoapi.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 06a74cd..7e065fa 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -29,6 +29,16 @@ static xs_str *random_str(void)
29} 29}
30 30
31 31
32const char *login_page = ""
33"<!DOCTYPE html>\n"
34"<body><h1>%s identify</h1>\n"
35"<form method=\"post\" action=\"https:/" "/%s/oauth/x-snac-login\">\n"
36"<p>Login: <input type=\"text\" name=\"login\"></p>\n"
37"<p>Password: <input type=\"password\" name=\"passwd\"></p>\n"
38"<input type=\"hidden\" name=\"redir\" value=\"%s\">\n"
39"</form><p>%s</p></body>\n"
40"";
41
32int oauth_get_handler(const xs_dict *req, const char *q_path, 42int oauth_get_handler(const xs_dict *req, const char *q_path,
33 char **body, int *b_size, char **ctype) 43 char **body, int *b_size, char **ctype)
34{ 44{
@@ -51,10 +61,11 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
51 const char *scope = xs_dict_get(msg, "scope"); 61 const char *scope = xs_dict_get(msg, "scope");
52 62
53 if (cid && ruri && rtype && strcmp(rtype, "code") == 0) { 63 if (cid && ruri && rtype && strcmp(rtype, "code") == 0) {
54 /* redirect to an identification page */ 64 const char *host = xs_dict_get(srv_config, "host");
55 status = 303; 65
56// *body = xs_fmt("%s/test1/admin?redir=%s", srv_baseurl, ruri); 66 *body = xs_fmt(login_page, host, host, ruri, USER_AGENT);
57 *body = xs_fmt("%s/test1/admin", srv_baseurl); 67 *ctype = "text/html";
68 status = 200;
58 } 69 }
59 else 70 else
60 status = 400; 71 status = 400;