@@ -410,26 +410,6 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
410410 website .ParentWebsiteID = parentWebsite .ID
411411 }
412412
413- if len (create .FtpUser ) != 0 && len (create .FtpPassword ) != 0 {
414- createFtpUser := func (t * task.Task ) error {
415- indexDir := GetSitePath (* website , SiteIndexDir )
416- itemID , err := NewIFtpService ().Create (dto.FtpCreate {User : create .FtpUser , Password : create .FtpPassword , Path : indexDir })
417- if err != nil {
418- createTask .Log (fmt .Sprintf ("create ftp for website failed, err: %v" , err ))
419- }
420- website .FtpID = itemID
421- return nil
422- }
423- deleteFtpUser := func (t * task.Task ) {
424- if website .FtpID > 0 {
425- if err = NewIFtpService ().Delete (dto.BatchDeleteReq {Ids : []uint {website .FtpID }}); err != nil {
426- createTask .Log (err .Error ())
427- }
428- }
429- }
430- createTask .AddSubTask (i18n .GetWithName ("ConfigFTP" , create .FtpUser ), createFtpUser , deleteFtpUser )
431- }
432-
433413 configNginx := func (t * task.Task ) error {
434414 if err = configDefaultNginx (website , domains , appInstall , runtime ); err != nil {
435415 return err
@@ -488,6 +468,19 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
488468 createTask .AddSubTaskWithIgnoreErr (i18n .GetMsgByKey ("EnableSSL" ), enableSSL )
489469 }
490470
471+ if len (create .FtpUser ) != 0 && len (create .FtpPassword ) != 0 {
472+ createFtpUser := func (t * task.Task ) error {
473+ indexDir := GetSitePath (* website , SiteIndexDir )
474+ itemID , err := NewIFtpService ().Create (dto.FtpCreate {User : create .FtpUser , Password : create .FtpPassword , Path : indexDir })
475+ if err != nil {
476+ return err
477+ }
478+ website .FtpID = itemID
479+ return nil
480+ }
481+ createTask .AddSubTaskWithIgnoreErr (i18n .GetWithName ("ConfigFTP" , create .FtpUser ), createFtpUser )
482+ }
483+
491484 return createTask .Execute ()
492485}
493486
@@ -2061,7 +2054,7 @@ func (w WebsiteService) GetPathAuthBasics(req request.NginxAuthReq) (res []respo
20612054 }
20622055 directives := config .Directives
20632056 location , _ := directives [0 ].(* components.Location )
2064- pathAuth .Path = location .Match
2057+ pathAuth .Path = strings . TrimPrefix ( location .Match , "^" )
20652058 passPath := path .Join (passDir , fmt .Sprintf ("%s.pass" , name ))
20662059 authContent , err = fileOp .GetContent (passPath )
20672060 if err != nil {
@@ -2130,7 +2123,7 @@ func (w WebsiteService) UpdatePathAuthBasic(req request.NginxPathAuthUpdate) err
21302123 directives := config .Directives
21312124 location , _ := directives [0 ].(* components.Location )
21322125 location .UpdateDirective ("auth_basic_user_file" , []string {fmt .Sprintf ("/www/sites/%s/path_auth/pass/%s" , website .Alias , fmt .Sprintf ("%s.pass" , req .Name ))})
2133- location .ChangePath ("~*" , req .Path )
2126+ location .ChangePath ("~*" , fmt . Sprintf ( "^%s" , req .Path ) )
21342127 var passwdHash []byte
21352128 passwdHash , err = bcrypt .GenerateFromPassword ([]byte (req .Password ), bcrypt .DefaultCost )
21362129 if err != nil {
0 commit comments