diff options
| author | 2024-04-18 17:13:31 +0200 | |
|---|---|---|
| committer | 2024-04-18 17:13:31 +0200 | |
| commit | 26840e0dc0e7322b2041c21b4e44ed9a34afff4b (patch) | |
| tree | 096c8e9c65df453f5e45bfde8ca8662b9a82c899 /mastoapi.c | |
| parent | Merge pull request 'Ability to federate with hidden networks #93 (update for ... (diff) | |
| download | snac2-26840e0dc0e7322b2041c21b4e44ed9a34afff4b.tar.gz snac2-26840e0dc0e7322b2041c21b4e44ed9a34afff4b.tar.xz snac2-26840e0dc0e7322b2041c21b4e44ed9a34afff4b.zip | |
Some tweaks to previous patch.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 20 |
1 files changed, 11 insertions, 9 deletions
| @@ -156,7 +156,7 @@ const char *login_page = "" | |||
| 156 | "</head>\n" | 156 | "</head>\n" |
| 157 | "<body><h1>%s OAuth identify</h1>\n" | 157 | "<body><h1>%s OAuth identify</h1>\n" |
| 158 | "<div style=\"background-color: red; color: white\">%s</div>\n" | 158 | "<div style=\"background-color: red; color: white\">%s</div>\n" |
| 159 | "<form method=\"post\" action=\"http:/" "/%s/%s\">\n" | 159 | "<form method=\"post\" action=\"%s:/" "/%s/%s\">\n" |
| 160 | "<p>Login: <input type=\"text\" name=\"login\"></p>\n" | 160 | "<p>Login: <input type=\"text\" name=\"login\"></p>\n" |
| 161 | "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n" | 161 | "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n" |
| 162 | "<input type=\"hidden\" name=\"redir\" value=\"%s\">\n" | 162 | "<input type=\"hidden\" name=\"redir\" value=\"%s\">\n" |
| @@ -193,11 +193,12 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 193 | 193 | ||
| 194 | if (app != NULL) { | 194 | if (app != NULL) { |
| 195 | const char *host = xs_dict_get(srv_config, "host"); | 195 | const char *host = xs_dict_get(srv_config, "host"); |
| 196 | const char *proto = xs_dict_get_def(srv_config, "protocol", "https"); | ||
| 196 | 197 | ||
| 197 | if (xs_is_null(state)) | 198 | if (xs_is_null(state)) |
| 198 | state = ""; | 199 | state = ""; |
| 199 | 200 | ||
| 200 | *body = xs_fmt(login_page, host, host, "", host, "oauth/x-snac-login", | 201 | *body = xs_fmt(login_page, host, host, "", proto, host, "oauth/x-snac-login", |
| 201 | ruri, cid, state, USER_AGENT); | 202 | ruri, cid, state, USER_AGENT); |
| 202 | *ctype = "text/html"; | 203 | *ctype = "text/html"; |
| 203 | status = 200; | 204 | status = 200; |
| @@ -213,8 +214,9 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 213 | else | 214 | else |
| 214 | if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ | 215 | if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ |
| 215 | const char *host = xs_dict_get(srv_config, "host"); | 216 | const char *host = xs_dict_get(srv_config, "host"); |
| 217 | const char *proto = xs_dict_get_def(srv_config, "protocol", "https"); | ||
| 216 | 218 | ||
| 217 | *body = xs_fmt(login_page, host, host, "", host, "oauth/x-snac-get-token", | 219 | *body = xs_fmt(login_page, host, host, "", proto, host, "oauth/x-snac-get-token", |
| 218 | "", "", "", USER_AGENT); | 220 | "", "", "", USER_AGENT); |
| 219 | *ctype = "text/html"; | 221 | *ctype = "text/html"; |
| 220 | status = 200; | 222 | status = 200; |
| @@ -265,11 +267,11 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 265 | const char *redir = xs_dict_get(args, "redir"); | 267 | const char *redir = xs_dict_get(args, "redir"); |
| 266 | const char *cid = xs_dict_get(args, "cid"); | 268 | const char *cid = xs_dict_get(args, "cid"); |
| 267 | const char *state = xs_dict_get(args, "state"); | 269 | const char *state = xs_dict_get(args, "state"); |
| 268 | 270 | const char *host = xs_dict_get(srv_config, "host"); | |
| 269 | const char *host = xs_dict_get(srv_config, "host"); | 271 | const char *proto = xs_dict_get_def(srv_config, "protocol", "https"); |
| 270 | 272 | ||
| 271 | /* by default, generate another login form with an error */ | 273 | /* by default, generate another login form with an error */ |
| 272 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", host, "oauth/x-snac-login", | 274 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", proto, host, "oauth/x-snac-login", |
| 273 | redir, cid, state, USER_AGENT); | 275 | redir, cid, state, USER_AGENT); |
| 274 | *ctype = "text/html"; | 276 | *ctype = "text/html"; |
| 275 | status = 200; | 277 | status = 200; |
| @@ -450,11 +452,11 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 450 | if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ | 452 | if (strcmp(cmd, "/x-snac-get-token") == 0) { /** **/ |
| 451 | const char *login = xs_dict_get(args, "login"); | 453 | const char *login = xs_dict_get(args, "login"); |
| 452 | const char *passwd = xs_dict_get(args, "passwd"); | 454 | const char *passwd = xs_dict_get(args, "passwd"); |
| 453 | 455 | const char *host = xs_dict_get(srv_config, "host"); | |
| 454 | const char *host = xs_dict_get(srv_config, "host"); | 456 | const char *proto = xs_dict_get_def(srv_config, "protocol", "https"); |
| 455 | 457 | ||
| 456 | /* by default, generate another login form with an error */ | 458 | /* by default, generate another login form with an error */ |
| 457 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", host, "oauth/x-snac-get-token", | 459 | *body = xs_fmt(login_page, host, host, "LOGIN INCORRECT", proto, host, "oauth/x-snac-get-token", |
| 458 | "", "", "", USER_AGENT); | 460 | "", "", "", USER_AGENT); |
| 459 | *ctype = "text/html"; | 461 | *ctype = "text/html"; |
| 460 | status = 200; | 462 | status = 200; |