Skip to content

Commit

Permalink
fix: login not working if root is protected
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed May 13, 2020
1 parent 8d6a511 commit 34d4adf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ function selectionMask() {
}//selectionMask
function showLogin(options) {
if (!HFS.sid) // the session was just deleted
return location.reload() // but it's necessary for login
var d = dialog('\
<form style="line-height:1.9em">\
Username\
Expand Down
13 changes: 6 additions & 7 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5060,7 +5060,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
procedure handleRequest();
var
dlForbiddenForWholeFolder, specialGrant: boolean;
urlCmd: string;
mode, urlCmd: string;
acc: Paccount;

function accessGranted(forceFile:Tfile=NIL):boolean;
Expand All @@ -5081,13 +5081,12 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
result:=f.accessFor(data);
// ok, you are referring a section of the template, which virtually resides in the root because of the url starting with /~
// but you don't have access rights to the root. We'll let you pass if it's actually a section and you are using it from a folder that you have access to.
if not result and (f = rootFile) and ansiStartsStr('~', urlCmd) and tpl.sectionExist(copy(urlCmd,2,MAXINT))
if not result and (f = rootFile)
and ((mode='section') or ansiStartsStr('~', urlCmd) and tpl.sectionExist(copy(urlCmd,2,MAXINT)))
and (0 < reMatch(conn.getHeader('Referer'), '://([^@]*@)?'+getSafeHost(data)+'(/.*)', 'i', 1, @m)) then
begin
fTemp:=findFileByUrl(m[2]);
result:=assigned(fTemp) and fTemp.accessFor(data);
specialGrant:=result;
freeIfTemp(Ftemp);
result:=TRUE;
specialGrant:=TRUE;
end;
if result then exit;
conn.reply.realm:=f.getShownRealm();
Expand Down Expand Up @@ -5200,7 +5199,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);

var
b: boolean;
s, mode: string;
s: string;
i: integer;
section: PtplSection;
begin
Expand Down

0 comments on commit 34d4adf

Please sign in to comment.