[PATCH links] More edge case bug fixes
Export this patch
---
admin/middleware.go | 2 +-
core/routes.go | 4 ++--
helpers.go | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/admin/middleware.go b/admin/middleware.go
index a6b19ee..3de32a3 100644
--- a/admin/middleware.go
+++ b/admin/middleware.go
@@ -12,7 +12,7 @@ func superUserRequierd() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
gctx := c.(*server.Context)
- if gctx.User.IsSuperUser() {
+ if gctx.User != nil && gctx.User.IsSuperUser() {
return next(c)
}
return echo.NotFoundHandler(c)
diff --git a/core/routes.go b/core/routes.go
index 39a13f6..2c2cf09 100644
--- a/core/routes.go
+++ b/core/routes.go
@@ -148,7 +148,7 @@ func (s *Service) Homepage(c echo.Context) error {
}
gctx := c.(*server.Context)
- if gctx.User.IsAuthenticated() {
+ if gctx.User != nil && gctx.User.IsAuthenticated() {
// Redirect logged in users to their home feed
return c.Redirect(http.StatusFound, c.Echo().Reverse(s.RouteName("home_link_list")))
}
@@ -3702,7 +3702,7 @@ func (s *Service) NoteDetail(c echo.Context) error {
"pd": pd,
"link": link,
"IsPrivate": link.IsPrivate(),
- "IsAuth": gctx.User.IsAuthenticated(),
+ "IsAuth": gctx.User != nil && gctx.User.IsAuthenticated(),
"navFlag": "notes",
"seoData": seoData,
}
diff --git a/helpers.go b/helpers.go
index 3a860bc..82f5143 100644
--- a/helpers.go
+++ b/helpers.go
@@ -1237,7 +1237,7 @@ func StripURLFragment(furl string) string {
func TagAbuseRedirect(c echo.Context) error {
gctx := c.(*server.Context)
tags := c.QueryParam("tag")
- if !gctx.User.IsAuthenticated() && tags != "" {
+ if (gctx.User == nil || !gctx.User.IsAuthenticated()) && tags != "" {
ntags := strings.Split(tags, ",")
if len(ntags) > 2 {
lt := localizer.GetSessionLocalizer(c)
--
2.49.1
Applied.
To git@git.code.netlandish.com:~netlandish/links
271d9a6..b250826 master -> master