commit bbbce7a
default
·
2023-04-08 07:27:22 +0000 UTC
parent 4964a56
The /oauth/authorize URL generates a login page.
1 files changed,
+15,
-4
+15,
-4
1@@ -29,6 +29,16 @@ static xs_str *random_str(void)
2 }
3
4
5+const char *login_page = ""
6+"<!DOCTYPE html>\n"
7+"<body><h1>%s identify</h1>\n"
8+"<form method=\"post\" action=\"https:/" "/%s/oauth/x-snac-login\">\n"
9+"<p>Login: <input type=\"text\" name=\"login\"></p>\n"
10+"<p>Password: <input type=\"password\" name=\"passwd\"></p>\n"
11+"<input type=\"hidden\" name=\"redir\" value=\"%s\">\n"
12+"</form><p>%s</p></body>\n"
13+"";
14+
15 int oauth_get_handler(const xs_dict *req, const char *q_path,
16 char **body, int *b_size, char **ctype)
17 {
18@@ -51,10 +61,11 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
19 const char *scope = xs_dict_get(msg, "scope");
20
21 if (cid && ruri && rtype && strcmp(rtype, "code") == 0) {
22- /* redirect to an identification page */
23- status = 303;
24-// *body = xs_fmt("%s/test1/admin?redir=%s", srv_baseurl, ruri);
25- *body = xs_fmt("%s/test1/admin", srv_baseurl);
26+ const char *host = xs_dict_get(srv_config, "host");
27+
28+ *body = xs_fmt(login_page, host, host, ruri, USER_AGENT);
29+ *ctype = "text/html";
30+ status = 200;
31 }
32 else
33 status = 400;