Made the post action configurable in login_page.

This commit is contained in:
default 2023-05-04 11:08:35 +02:00
parent 980a8d524f
commit f6ef275fa3

View File

@ -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();