mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-28 03:06:20 -04:00
Use formhist for 401 Unauthorized and others.
This commit is contained in:
parent
9a001f051a
commit
ddc0d8d7be
@ -9,6 +9,8 @@
|
|||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "bfu/dialog.h"
|
#include "bfu/dialog.h"
|
||||||
|
#include "document/forms.h"
|
||||||
|
#include "formhist/formhist.h"
|
||||||
#include "intl/gettext/libintl.h"
|
#include "intl/gettext/libintl.h"
|
||||||
#include "main/object.h"
|
#include "main/object.h"
|
||||||
#include "protocol/auth/auth.h"
|
#include "protocol/auth/auth.h"
|
||||||
@ -23,6 +25,7 @@
|
|||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/snprintf.h"
|
#include "util/snprintf.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
#include "viewer/text/form.h"
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -35,6 +38,33 @@ auth_ok(void *data)
|
|||||||
entry->blocked = 0;
|
entry->blocked = 0;
|
||||||
entry->valid = auth_entry_has_userinfo(entry);
|
entry->valid = auth_entry_has_userinfo(entry);
|
||||||
|
|
||||||
|
#ifdef CONFIG_FORMHIST
|
||||||
|
{
|
||||||
|
unsigned char *url = get_uri_string(entry->uri, URI_HTTP_AUTH);
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
struct form form = {
|
||||||
|
.action = url,
|
||||||
|
};
|
||||||
|
INIT_LIST_OF(struct submitted_value, submit);
|
||||||
|
struct submitted_value *user, *password;
|
||||||
|
|
||||||
|
user = init_submitted_value("user", entry->user, FC_TEXT, NULL, 0);
|
||||||
|
if (user) {
|
||||||
|
add_to_list(submit, user);
|
||||||
|
}
|
||||||
|
password = init_submitted_value("password", entry->password, FC_PASSWORD, NULL, 0);
|
||||||
|
if (password) {
|
||||||
|
add_to_list(submit, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
memorize_form(ses, &submit, &form);
|
||||||
|
done_submitted_value_list(&submit);
|
||||||
|
mem_free(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (entry->valid && have_location(ses)) {
|
if (entry->valid && have_location(ses)) {
|
||||||
struct location *loc = cur_loc(ses);
|
struct location *loc = cur_loc(ses);
|
||||||
struct uri *uri = loc->vs.uri;
|
struct uri *uri = loc->vs.uri;
|
||||||
@ -83,6 +113,20 @@ do_auth_dialog(struct session *ses, void *data)
|
|||||||
text = get_uri_string(a->uri, URI_HTTP_AUTH);
|
text = get_uri_string(a->uri, URI_HTTP_AUTH);
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
|
||||||
|
#ifdef CONFIG_FORMHIST
|
||||||
|
{
|
||||||
|
unsigned char *user = get_form_history_value(text, "user");
|
||||||
|
unsigned char *password = get_form_history_value(text, "password");
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
strncpy(a->user, user, AUTH_USER_MAXLEN - 1);
|
||||||
|
}
|
||||||
|
if (password) {
|
||||||
|
strncpy(a->password, password, AUTH_PASSWORD_MAXLEN - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sticker_len = snprintf(sticker, sizeof(sticker),
|
sticker_len = snprintf(sticker, sizeof(sticker),
|
||||||
_("Authentication required for %s at %s", term),
|
_("Authentication required for %s at %s", term),
|
||||||
a->realm, text);
|
a->realm, text);
|
||||||
|
Loading…
Reference in New Issue
Block a user