diff options
author | default <nobody@localhost> | 2023-04-08 09:27:22 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-04-08 09:27:22 +0200 |
commit | bbbce7afac01d385a4a3650d94e501fa87205bfa (patch) | |
tree | 2ab7fdccf5a68fc2d37a29685b6034f1231cec83 /mastoapi.c | |
parent | 4964a564560fb81a505179ae7d9730d2231a743c (diff) |
The /oauth/authorize URL generates a login page.
Diffstat (limited to 'mastoapi.c')
-rw-r--r-- | mastoapi.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -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; |