@@ -41,11 +41,10 @@ type sessionContext struct {
4141
4242 allowAccess bool
4343
44- needAuth bool
45- requestAuth bool
46- authUserId int
47- authUserName string
48- authSuccess bool
44+ needAuth bool
45+ requestAuth bool
46+ authUserId int
47+ authSuccess bool
4948
5049 redirectAction redirectAction
5150 vary string
@@ -59,6 +58,8 @@ type sessionContext struct {
5958}
6059
6160type responseData struct {
61+ AuthUserName string
62+
6263 IsDownload bool
6364 IsDownloadFile bool
6465 IsUpload bool
@@ -336,13 +337,11 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
336337 status := http .StatusOK
337338
338339 needAuth , requestAuth := h .needAuth (rawQuery , vhostReqPath , fsPath )
339- authUserId , authUserName , _authErr := h .verifyAuth (r , needAuth , vhostReqPath , fsPath )
340- authSuccess := _authErr == nil
341- if needAuth && ! authSuccess {
342- errs = append (errs , _authErr )
343- }
340+ authUserId , authUserName , _authErr := h .verifyAuth (r , vhostReqPath , fsPath )
341+ authSuccess := ! needAuth || _authErr == nil
344342 if ! authSuccess {
345343 status = http .StatusUnauthorized
344+ errs = append (errs , _authErr )
346345 }
347346
348347 headers := h .getHeaders (vhostReqPath , fsPath , authSuccess )
@@ -477,11 +476,10 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
477476
478477 allowAccess : allowAccess ,
479478
480- needAuth : needAuth ,
481- requestAuth : requestAuth ,
482- authUserId : authUserId ,
483- authUserName : authUserName ,
484- authSuccess : authSuccess ,
479+ needAuth : needAuth ,
480+ requestAuth : requestAuth ,
481+ authUserId : authUserId ,
482+ authSuccess : authSuccess ,
485483
486484 redirectAction : redirectAction ,
487485 vary : vary ,
@@ -494,6 +492,8 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
494492 errors : errs ,
495493 }
496494 data = & responseData {
495+ AuthUserName : authUserName ,
496+
497497 IsDownload : isDownload ,
498498 IsDownloadFile : isDownloadFile ,
499499 IsUpload : isUpload ,
0 commit comments