summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-05-04 11:08:35 +0200
committerdefault <nobody@localhost>2023-05-04 11:08:35 +0200
commitf6ef275fa3dfd0e74093a5eb74a5167f7be4ece0 (patch)
tree6501dac7e61710567676f55fb2f04220b710b2ed
parent980a8d524fae11d17366e7aea56206d13f278e31 (diff)
Made the post action configurable in login_page.
-rw-r--r--mastoapi.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/mastoapi.c b/mastoapi.c
index c333573..4396155 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -162,7 +162,7 @@ const char *login_page = ""
"<!DOCTYPE html>\n"
"<body><h1>%s OAuth identify</h1>\n"
"<div style=\"background-color: red; color: white\">%s</div>\n"
-"<form method=\"post\" action=\"https:/" "/%s/oauth/x-snac-login\">\n"
+"<form method=\"post\" action=\"https:/" "/%s/%s\">\n"
"<p>Login: <input type=\"text\" name=\"login\"></p>\n"
"<p>Password: <input type=\"password\" name=\"passwd\"></p>\n"
"<input type=\"hidden\" name=\"redir\" value=\"%s\">\n"
@@ -208,7 +208,8 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
if (xs_is_null(state))
state = "";
- *body = xs_fmt(login_page, host, "", host, ruri, cid, state, USER_AGENT);
+ *body = xs_fmt(login_page, host, "", host, "oauth/x-snac-login",
+ ruri, cid, state, USER_AGENT);
*ctype = "text/html";
status = 200;
@@ -264,7 +265,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
const char *host = xs_dict_get(srv_config, "host");
/* by default, generate another login form with an error */
- *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, redir, cid, state, USER_AGENT);
+ *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, "oauth/x-snac-login",
+ redir, cid, state, USER_AGENT);
*ctype = "text/html";
status = 200;
@@ -273,8 +275,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
if (user_open(&snac, login)) {
/* check the login + password */
- if (check_password(login, passwd,
- xs_dict_get(snac.config, "passwd"))) {
+ if (check_password(login, passwd, xs_dict_get(snac.config, "passwd"))) {
/* success! redirect to the desired uri */
xs *code = random_str();