use new login when accessing protected files directly

This commit is contained in:
Massimo Melina 2020-05-13 19:53:59 +02:00
parent 20097bc715
commit 1b59836f4e
4 changed files with 11 additions and 27 deletions

BIN
data.RES Normal file

Binary file not shown.

View File

@ -437,23 +437,8 @@ z-index:1; /* without this .item-menu will be over*/ }
{.123 if 2|<div class='comment'><i class="fa fa-quote-left"></i><span class="comment-text">|{.commentNL|%item-comment%.}|</span></div>.} {.123 if 2|<div class='comment'><i class="fa fa-quote-left"></i><span class="comment-text">|{.commentNL|%item-comment%.}|</span></div>.}
</div> </div>
[login]
{.$common-head.}
<title>{.!HFS.} %folder%</title>
</head>
<body onload="showLogin({ closable:false })">
</body>
</html>
[error-page] [error-page]
<!DOCTYPE html> {.$common-head.}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
{.$style.css.}
</style>
</head> </head>
<body> <body>
%content% %content%
@ -464,6 +449,10 @@ z-index:1; /* without this .item-menu will be over*/ }
</body> </body>
</html> </html>
[login]
<h1>{.!Login required.}</h1>
<script>showLogin({ closable:false })</script>
[not found] [not found]
<h1>{.!Not found.}</h1> <h1>{.!Not found.}</h1>
<a href="/">{.!go to root.}</a> <a href="/">{.!go to root.}</a>

View File

@ -3917,6 +3917,7 @@ try
data.conn.reply.contentType:=ansistring(name2mimetype(sectionName, 'text/html')); data.conn.reply.contentType:=ansistring(name2mimetype(sectionName, 'text/html'));
if sectionName = 'ban' then data.conn.reply.mode:=HRM_DENY; if sectionName = 'ban' then data.conn.reply.mode:=HRM_DENY;
if sectionName = 'deny' then data.conn.reply.mode:=HRM_DENY; if sectionName = 'deny' then data.conn.reply.mode:=HRM_DENY;
if sectionName = 'login' then data.conn.reply.mode:=HRM_DENY;
if sectionName = 'not found' then data.conn.reply.mode:=HRM_NOT_FOUND; if sectionName = 'not found' then data.conn.reply.mode:=HRM_NOT_FOUND;
if sectionName = 'unauthorized' then data.conn.reply.mode:=HRM_UNAUTHORIZED; if sectionName = 'unauthorized' then data.conn.reply.mode:=HRM_UNAUTHORIZED;
if sectionName = 'overload' then data.conn.reply.mode:=HRM_OVERLOAD; if sectionName = 'overload' then data.conn.reply.mode:=HRM_OVERLOAD;
@ -5089,15 +5090,9 @@ var
freeIfTemp(Ftemp); freeIfTemp(Ftemp);
end; end;
if result then exit; if result then exit;
if f.isFolder() then
begin
conn.reply.mode:=HRM_REPLY;
getPage('login', data, f);
exit;
end;
conn.reply.realm:=f.getShownRealm(); conn.reply.realm:=f.getShownRealm();
runEventScript('unauthorized'); runEventScript('unauthorized');
getPage('unauthorized', data); getPage('login', data, f);
// log anyone trying to guess the password // log anyone trying to guess the password
if (forceFile = NIL) and stringExists(data.user, getAccountList(TRUE, FALSE)) if (forceFile = NIL) and stringExists(data.user, getAccountList(TRUE, FALSE))
and logOtherEventsChk.checked then and logOtherEventsChk.checked then

View File

@ -2495,7 +2495,7 @@ var
left, right: real; left, right: real;
leftS, rightS: string; leftS, rightS: string;
function getOperate(dir:integer):string; function getOperand(dir:integer):string;
var var
j: integer; j: integer;
begin begin
@ -2511,7 +2511,7 @@ var
swapMem(i, j, sizeOf(i), dir > 0); swapMem(i, j, sizeOf(i), dir > 0);
j:=j-i+1; j:=j-i+1;
result:=copy(s, i, j); result:=copy(s, i, j);
end; // getOperate end; // getOperand
begin begin
repeat repeat
@ -2546,8 +2546,8 @@ begin
exit; exit;
end; end;
// determine operates // determine operates
leftS:=getOperate(-1); leftS:=getOperand(-1);
rightS:=getOperate(+1); rightS:=getOperand(+1);
left:=StrToFloatDef(trim(leftS), 0); left:=StrToFloatDef(trim(leftS), 0);
right:=strToFloat(trim(rightS)); right:=strToFloat(trim(rightS));
// calculate // calculate