feat(seo): response not found page when private mode

This commit is contained in:
LinkinStar 2022-12-13 14:17:36 +08:00
parent 392806b146
commit f288e1f8b7
1 changed files with 20 additions and 0 deletions

View File

@ -404,10 +404,18 @@ func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteI
}
func (tc *TemplateController) Sitemap(ctx *gin.Context) {
if tc.checkPrivateMode(ctx) {
tc.Page404(ctx)
return
}
tc.templateRenderController.Sitemap(ctx)
}
func (tc *TemplateController) SitemapPage(ctx *gin.Context) {
if tc.checkPrivateMode(ctx) {
tc.Page404(ctx)
return
}
page := 0
pageParam := ctx.Param("page")
pageRegexp := regexp.MustCompile(`question-(.*).xml`)
@ -427,3 +435,15 @@ func (tc *TemplateController) SitemapPage(ctx *gin.Context) {
return
}
}
func (tc *TemplateController) checkPrivateMode(ctx *gin.Context) bool {
resp, err := tc.siteInfoService.GetSiteLogin(ctx)
if err != nil {
log.Error(err)
return false
}
if resp.LoginRequired {
return true
}
return false
}