fix a bunch of bookmarklets login forms not leading back

This commit is contained in:
Andrew Dolgov 2021-03-04 13:40:54 +03:00
parent 30765805fd
commit 4fda5ccd0e
5 changed files with 19 additions and 6 deletions

View File

@ -834,9 +834,12 @@ class Handler_Public extends Handler {
}
}
static function _render_login_form() {
static function _render_login_form(string $return_to = "") {
header('Cache-Control: public');
if ($return_to)
$_REQUEST['return'] = $return_to;
require_once "login_form.php";
exit;
}

View File

@ -236,6 +236,14 @@
}
}
function with_trailing_slash(string $str) : string {
if (substr($str, -1) === "/") {
return $str;
} else {
return "$str/";
}
}
function make_password($length = 12) {
$password = "";
$possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^";

View File

@ -85,7 +85,7 @@
</script>
<?php $return = urlencode(Config::make_self_url()) ?>
<?php $return = urlencode($_REQUEST['return'] ? $_REQUEST['return'] : with_trailing_slash(Config::make_self_url())) ?>
<div class="container">

View File

@ -100,7 +100,7 @@ class Auth_Internal extends Auth_Base {
<body class="flat ttrss_utility otp css_loading">
<h1><?= __("Authentication") ?></h1>
<div class="content">
<form dojoType="dijit.form.Form" action="public.php?return=<?= $return ?>" method="post" class="otpform">
<form dojoType="dijit.form.Form" action="public.php?return=<?= urlencode(with_trailing_slash($return)) ?>" method="post" class="otpform">
<?php foreach (["login", "password", "bw_limit", "safe_mode", "remember_me", "profile"] as $key) {
print \Controls\hidden_tag($key, $_POST[$key] ?? "");

View File

@ -167,7 +167,7 @@ class Bookmarklets extends Plugin {
</html>
<?php
} else {
Handler_Public::_render_login_form();
Handler_Public::_render_login_form($this->host->get_public_method_url($this, "subscribe"));
}
}
@ -289,10 +289,12 @@ class Bookmarklets extends Plugin {
}
} else {
print_error("Not logged in");
$return_to = $this->host->get_public_method_url($this, "sharepopup");
?>
<form action="public.php?return=<?= urlencode(Config::make_self_url()) ?>" method="post">
<?= format_error("Not logged in") ?>
<form action="public.php?return=<?= urlencode($return_to) ?>" method="post">
<input type="hidden" name="op" value="login">