mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
show login prompt on 404
This commit is contained in:
parent
44e5c82e6d
commit
abc0424c26
|
@ -385,7 +385,7 @@ class HttpCli(object):
|
|||
if not self.can_read and not self.can_write and not self.can_get:
|
||||
if self.vpath:
|
||||
self.log("inaccessible: [{}]".format(self.vpath))
|
||||
raise Pebkac(404)
|
||||
return self.tx_404()
|
||||
|
||||
self.uparam["h"] = False
|
||||
|
||||
|
@ -889,8 +889,12 @@ class HttpCli(object):
|
|||
pwd = self.parser.require("cppwd", 64)
|
||||
self.parser.drop()
|
||||
|
||||
dst = "/?h"
|
||||
if self.vpath:
|
||||
dst = "/" + quotep(self.vpath)
|
||||
|
||||
ck, msg = self.get_pwd_cookie(pwd)
|
||||
html = self.j2("msg", h1=msg, h2='<a href="/?h">ack</a>', redir="/?h")
|
||||
html = self.j2("msg", h1=msg, h2='<a href="' + dst + '">ack</a>', redir=dst)
|
||||
self.reply(html.encode("utf-8"), headers={"Set-Cookie": ck})
|
||||
return True
|
||||
|
||||
|
@ -1279,7 +1283,7 @@ class HttpCli(object):
|
|||
break
|
||||
|
||||
if not editions:
|
||||
raise Pebkac(404)
|
||||
return self.tx_404()
|
||||
|
||||
#
|
||||
# if-modified
|
||||
|
@ -1598,6 +1602,7 @@ class HttpCli(object):
|
|||
html = self.j2(
|
||||
"splash",
|
||||
this=self,
|
||||
qvpath=quotep(self.vpath),
|
||||
rvol=rvol,
|
||||
wvol=wvol,
|
||||
avol=avol,
|
||||
|
@ -1611,6 +1616,12 @@ class HttpCli(object):
|
|||
self.reply(html.encode("utf-8"))
|
||||
return True
|
||||
|
||||
def tx_404(self):
|
||||
m = '<h1>404 not found</h1><p>or maybe you don\'t have access -- try logging in or <a href="/?h">go home</a></p>'
|
||||
html = self.j2("splash", this=self, qvpath=quotep(self.vpath), msg=m)
|
||||
self.reply(html.encode("utf-8"), status=404)
|
||||
return True
|
||||
|
||||
def scanvol(self):
|
||||
if not self.can_read or not self.can_write:
|
||||
raise Pebkac(403, "not allowed for user " + self.uname)
|
||||
|
@ -1784,7 +1795,7 @@ class HttpCli(object):
|
|||
try:
|
||||
st = bos.stat(abspath)
|
||||
except:
|
||||
raise Pebkac(404)
|
||||
return self.tx_404()
|
||||
|
||||
if rem.startswith(".hist/up2k.") or (
|
||||
rem.endswith("/dir.txt") and rem.startswith(".hist/th/")
|
||||
|
@ -1926,7 +1937,7 @@ class HttpCli(object):
|
|||
return True
|
||||
|
||||
if not stat.S_ISDIR(st.st_mode):
|
||||
raise Pebkac(404)
|
||||
return self.tx_404()
|
||||
|
||||
if "zip" in self.uparam or "tar" in self.uparam:
|
||||
raise Pebkac(403)
|
||||
|
|
|
@ -571,7 +571,7 @@ html.light #wfm a:not(.en) {
|
|||
padding: .5em;
|
||||
border-radius: 0 1em 1em 0;
|
||||
border-width: .15em .3em .3em 0;
|
||||
max-width: 40em;
|
||||
max-width: 41em;
|
||||
}
|
||||
.opbox input {
|
||||
margin: .5em;
|
||||
|
|
|
@ -55,6 +55,16 @@ table {
|
|||
.btns {
|
||||
margin: 1em 0;
|
||||
}
|
||||
#msg {
|
||||
margin: 3em 0;
|
||||
}
|
||||
#msg h1 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#msg h1 + p {
|
||||
margin-top: .3em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
html.dark,
|
||||
|
|
|
@ -12,7 +12,17 @@
|
|||
|
||||
<body>
|
||||
<div id="wrap">
|
||||
<p>hello {{ this.uname }}</p>
|
||||
{%- if this.uname == '*' %}
|
||||
<p>howdy stranger <small>(you're not logged in)</small></p>
|
||||
{%- else %}
|
||||
<p>welcome back, <strong>{{ this.uname }}</strong></p>
|
||||
{%- endif %}
|
||||
|
||||
{%- if msg %}
|
||||
<div id="msg">
|
||||
{{ msg }}
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
{%- if avol %}
|
||||
<h1>admin panel:</h1>
|
||||
|
@ -60,7 +70,7 @@
|
|||
|
||||
<h1>login for more:</h1>
|
||||
<ul>
|
||||
<form method="post" enctype="multipart/form-data" action="/">
|
||||
<form method="post" enctype="multipart/form-data" action="/{{ qvpath }}">
|
||||
<input type="hidden" name="act" value="login" />
|
||||
<input type="password" name="cppwd" />
|
||||
<input type="submit" value="Login" />
|
||||
|
|
|
@ -41,9 +41,9 @@ avg() { awk 'function pr(ncsz) {if (nsmp>0) {printf "%3s %s\n", csz, sum/nsmp} c
|
|||
##
|
||||
## bad filenames
|
||||
|
||||
dirs=("$HOME/vfs/ほげ" "$HOME/vfs/ほげ/ぴよ" "$HOME/vfs/$(printf \\xed\\x91)" "$HOME/vfs/$(printf \\xed\\x91/\\xed\\x92)")
|
||||
dirs=("./ほげ" "./ほげ/ぴよ" "./$(printf \\xed\\x91)" "./$(printf \\xed\\x91/\\xed\\x92)" './qw,er;ty%20as df?gh+jkl%zxc&vbn <qwe>"rty'"'"'uio&asd fgh')
|
||||
mkdir -p "${dirs[@]}"
|
||||
for dir in "${dirs[@]}"; do for fn in ふが "$(printf \\xed\\x93)" 'qwe,rty;asd fgh+jkl%zxc&vbn <qwe>"rty'"'"'uio&asd fgh'; do echo "$dir" > "$dir/$fn.html"; done; done
|
||||
for dir in "${dirs[@]}"; do for fn in ふが "$(printf \\xed\\x93)" 'qw,er;ty%20as df?gh+jkl%zxc&vbn <qwe>"rty'"'"'uio&asd fgh'; do echo "$dir" > "$dir/$fn.html"; done; done
|
||||
# qw er+ty%20ui%%20op<as>df&gh&jk#zx'cv"bn`m=qw*er^ty?ui@op,as.df-gh_jk
|
||||
|
||||
##
|
||||
|
|
Loading…
Reference in a new issue