@@ -1852,21 +1852,15 @@ func (w WebsiteService) ClearProxyCache(req request.NginxCommonReq) error {
18521852
18531853func (w WebsiteService ) GetAuthBasics (req request.NginxAuthReq ) (res response.NginxAuthRes , err error ) {
18541854 var (
1855- website model.Website
1856- nginxInstall model.AppInstall
1857- authContent []byte
1858- nginxParams []response.NginxParam
1855+ website model.Website
1856+ authContent []byte
1857+ nginxParams []response.NginxParam
18591858 )
18601859 website , err = websiteRepo .GetFirst (repo .WithByID (req .WebsiteID ))
18611860 if err != nil {
18621861 return
18631862 }
1864- nginxInstall , err = getAppInstallByKey (constant .AppOpenresty )
1865- if err != nil {
1866- return
1867- }
1868- authPath := fmt .Sprintf ("/www/sites/%s/auth_basic/auth.pass" , website .Alias )
1869- absoluteAuthPath := path .Join (nginxInstall .GetPath (), authPath )
1863+ absoluteAuthPath := GetSitePath (website , SiteRootAuthBasicPath )
18701864 fileOp := files .NewFileOp ()
18711865 if ! fileOp .Stat (absoluteAuthPath ) {
18721866 return
@@ -1896,22 +1890,17 @@ func (w WebsiteService) GetAuthBasics(req request.NginxAuthReq) (res response.Ng
18961890
18971891func (w WebsiteService ) UpdateAuthBasic (req request.NginxAuthUpdate ) (err error ) {
18981892 var (
1899- website model.Website
1900- nginxInstall model.AppInstall
1901- params []dto.NginxParam
1902- authContent []byte
1903- authArray []string
1893+ website model.Website
1894+ params []dto.NginxParam
1895+ authContent []byte
1896+ authArray []string
19041897 )
19051898 website , err = websiteRepo .GetFirst (repo .WithByID (req .WebsiteID ))
19061899 if err != nil {
19071900 return err
19081901 }
1909- nginxInstall , err = getAppInstallByKey (constant .AppOpenresty )
1910- if err != nil {
1911- return
1912- }
19131902 authPath := fmt .Sprintf ("/www/sites/%s/auth_basic/auth.pass" , website .Alias )
1914- absoluteAuthPath := path . Join ( nginxInstall . GetPath (), authPath )
1903+ absoluteAuthPath := GetSitePath ( website , SiteRootAuthBasicPath )
19151904 fileOp := files .NewFileOp ()
19161905 if ! fileOp .Stat (path .Dir (absoluteAuthPath )) {
19171906 _ = fileOp .CreateDir (path .Dir (absoluteAuthPath ), constant .DirPerm )
@@ -2025,21 +2014,15 @@ func (w WebsiteService) UpdateAuthBasic(req request.NginxAuthUpdate) (err error)
20252014
20262015func (w WebsiteService ) GetPathAuthBasics (req request.NginxAuthReq ) (res []response.NginxPathAuthRes , err error ) {
20272016 var (
2028- website model.Website
2029- nginxInstall model.AppInstall
2030- authContent []byte
2017+ website model.Website
2018+ authContent []byte
20312019 )
20322020 website , err = websiteRepo .GetFirst (repo .WithByID (req .WebsiteID ))
20332021 if err != nil {
20342022 return
20352023 }
2036- nginxInstall , err = getAppInstallByKey (constant .AppOpenresty )
2037- if err != nil {
2038- return
2039- }
20402024 fileOp := files .NewFileOp ()
2041- authDir := fmt .Sprintf ("/www/sites/%s/path_auth" , website .Alias )
2042- absoluteAuthDir := path .Join (nginxInstall .GetPath (), authDir )
2025+ absoluteAuthDir := GetSitePath (website , SitePathAuthBasicDir )
20432026 passDir := path .Join (absoluteAuthDir , "pass" )
20442027 if ! fileOp .Stat (absoluteAuthDir ) || ! fileOp .Stat (passDir ) {
20452028 return
@@ -2097,12 +2080,8 @@ func (w WebsiteService) UpdatePathAuthBasic(req request.NginxPathAuthUpdate) err
20972080 if err != nil {
20982081 return err
20992082 }
2100- nginxInstall , err := getAppInstallByKey (constant .AppOpenresty )
2101- if err != nil {
2102- return err
2103- }
21042083 fileOp := files .NewFileOp ()
2105- authDir := path . Join ( nginxInstall . GetPath (), "www" , "sites" , website . Alias , "path_auth" )
2084+ authDir := GetSitePath ( website , SitePathAuthBasicDir )
21062085 if ! fileOp .Stat (authDir ) {
21072086 _ = fileOp .CreateDir (authDir , constant .DirPerm )
21082087 }
0 commit comments