mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
The /oauth/authorize URL generates a login page.
This commit is contained in:
parent
4964a56456
commit
bbbce7afac
1 changed files with 15 additions and 4 deletions
19
mastoapi.c
19
mastoapi.c
|
@ -29,6 +29,16 @@ static xs_str *random_str(void)
|
|||
}
|
||||
|
||||
|
||||
const char *login_page = ""
|
||||
"<!DOCTYPE html>\n"
|
||||
"<body><h1>%s identify</h1>\n"
|
||||
"<form method=\"post\" action=\"https:/" "/%s/oauth/x-snac-login\">\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"
|
||||
"</form><p>%s</p></body>\n"
|
||||
"";
|
||||
|
||||
int oauth_get_handler(const xs_dict *req, const char *q_path,
|
||||
char **body, int *b_size, char **ctype)
|
||||
{
|
||||
|
@ -51,10 +61,11 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
|
|||
const char *scope = xs_dict_get(msg, "scope");
|
||||
|
||||
if (cid && ruri && rtype && strcmp(rtype, "code") == 0) {
|
||||
/* redirect to an identification page */
|
||||
status = 303;
|
||||
// *body = xs_fmt("%s/test1/admin?redir=%s", srv_baseurl, ruri);
|
||||
*body = xs_fmt("%s/test1/admin", srv_baseurl);
|
||||
const char *host = xs_dict_get(srv_config, "host");
|
||||
|
||||
*body = xs_fmt(login_page, host, host, ruri, USER_AGENT);
|
||||
*ctype = "text/html";
|
||||
status = 200;
|
||||
}
|
||||
else
|
||||
status = 400;
|
||||
|
|
Loading…
Reference in a new issue