commit f6ef275
default
·
2023-05-04 09:08:35 +0000 UTC
parent 980a8d5
Made the post action configurable in login_page.
1 files changed,
+6,
-5
+6,
-5
1@@ -162,7 +162,7 @@ const char *login_page = ""
2 "<!DOCTYPE html>\n"
3 "<body><h1>%s OAuth identify</h1>\n"
4 "<div style=\"background-color: red; color: white\">%s</div>\n"
5-"<form method=\"post\" action=\"https:/" "/%s/oauth/x-snac-login\">\n"
6+"<form method=\"post\" action=\"https:/" "/%s/%s\">\n"
7 "<p>Login: <input type=\"text\" name=\"login\"></p>\n"
8 "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n"
9 "<input type=\"hidden\" name=\"redir\" value=\"%s\">\n"
10@@ -208,7 +208,8 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
11 if (xs_is_null(state))
12 state = "";
13
14- *body = xs_fmt(login_page, host, "", host, ruri, cid, state, USER_AGENT);
15+ *body = xs_fmt(login_page, host, "", host, "oauth/x-snac-login",
16+ ruri, cid, state, USER_AGENT);
17 *ctype = "text/html";
18 status = 200;
19
20@@ -264,7 +265,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
21 const char *host = xs_dict_get(srv_config, "host");
22
23 /* by default, generate another login form with an error */
24- *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, redir, cid, state, USER_AGENT);
25+ *body = xs_fmt(login_page, host, "LOGIN INCORRECT", host, "oauth/x-snac-login",
26+ redir, cid, state, USER_AGENT);
27 *ctype = "text/html";
28 status = 200;
29
30@@ -273,8 +275,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
31
32 if (user_open(&snac, login)) {
33 /* check the login + password */
34- if (check_password(login, passwd,
35- xs_dict_get(snac.config, "passwd"))) {
36+ if (check_password(login, passwd, xs_dict_get(snac.config, "passwd"))) {
37 /* success! redirect to the desired uri */
38 xs *code = random_str();
39