diff options
| author | 2023-05-04 11:08:35 +0200 | |
|---|---|---|
| committer | 2023-05-04 11:08:35 +0200 | |
| commit | f6ef275fa3dfd0e74093a5eb74a5167f7be4ece0 (patch) | |
| tree | 6501dac7e61710567676f55fb2f04220b710b2ed /mastoapi.c | |
| parent | Fixed more warnings. (diff) | |
| download | snac2-f6ef275fa3dfd0e74093a5eb74a5167f7be4ece0.tar.gz snac2-f6ef275fa3dfd0e74093a5eb74a5167f7be4ece0.tar.xz snac2-f6ef275fa3dfd0e74093a5eb74a5167f7be4ece0.zip | |
Made the post action configurable in login_page.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 11 |
1 files changed, 6 insertions, 5 deletions
| @@ -162,7 +162,7 @@ const char *login_page = "" | |||
| 162 | "<!DOCTYPE html>\n" | 162 | "<!DOCTYPE html>\n" |
| 163 | "<body><h1>%s OAuth identify</h1>\n" | 163 | "<body><h1>%s OAuth identify</h1>\n" |
| 164 | "<div style=\"background-color: red; color: white\">%s</div>\n" | 164 | "<div style=\"background-color: red; color: white\">%s</div>\n" |
| 165 | "<form method=\"post\" action=\"https:/" "/%s/oauth/x-snac-login\">\n" | 165 | "<form method=\"post\" action=\"https:/" "/%s/%s\">\n" |
| 166 | "<p>Login: <input type=\"text\" name=\"login\"></p>\n" | 166 | "<p>Login: <input type=\"text\" name=\"login\"></p>\n" |
| 167 | "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n" | 167 | "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n" |
| 168 | "<input type=\"hidden\" name=\"redir\" value=\"%s\">\n" | 168 | "<input type=\"hidden\" name=\"redir\" value=\"%s\">\n" |
| @@ -208,7 +208,8 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 208 | if (xs_is_null(state)) | 208 | if (xs_is_null(state)) |
| 209 | state = ""; | 209 | state = ""; |
| 210 | 210 | ||
| 211 | *body = xs_fmt(login_page, host, "", host, ruri, cid, state, USER_AGENT); | 211 | *body = xs_fmt(login_page, host, "", host, "oauth/x-snac-login", |
| 212 | ruri, cid, state, USER_AGENT); | ||
| 212 | *ctype = "text/html"; | 213 | *ctype = "text/html"; |
| 213 | status = 200; | 214 | status = 200; |
| 214 | 215 | ||
| @@ -264,7 +265,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 264 | const char *host = xs_dict_get(srv_config, "host"); | 265 | const char *host = xs_dict_get(srv_config, "host"); |
| 265 | 266 | ||
| 266 | /* by default, generate another login form with an error */ | 267 | /* by default, generate another login form with an error */ |
| 267 | *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, redir, cid, state, USER_AGENT); | 268 | *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, "oauth/x-snac-login", |
| 269 | redir, cid, state, USER_AGENT); | ||
| 268 | *ctype = "text/html"; | 270 | *ctype = "text/html"; |
| 269 | status = 200; | 271 | status = 200; |
| 270 | 272 | ||
| @@ -273,8 +275,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 273 | 275 | ||
| 274 | if (user_open(&snac, login)) { | 276 | if (user_open(&snac, login)) { |
| 275 | /* check the login + password */ | 277 | /* check the login + password */ |
| 276 | if (check_password(login, passwd, | 278 | if (check_password(login, passwd, xs_dict_get(snac.config, "passwd"))) { |
| 277 | xs_dict_get(snac.config, "passwd"))) { | ||
| 278 | /* success! redirect to the desired uri */ | 279 | /* success! redirect to the desired uri */ |
| 279 | xs *code = random_str(); | 280 | xs *code = random_str(); |
| 280 | 281 | ||