summaryrefslogtreecommitdiffstats
path: root/web/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'web/middleware')
-rw-r--r--web/middleware/auth.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/web/middleware/auth.go b/web/middleware/auth.go
index c0257e2..5feccfe 100644
--- a/web/middleware/auth.go
+++ b/web/middleware/auth.go
@@ -6,6 +6,7 @@ import (
"html/template"
"log/slog"
"net/http"
+ "net/url"
"git.leonardobishop.net/instancer/pkg/auth"
"git.leonardobishop.net/instancer/pkg/session"
@@ -22,14 +23,14 @@ func MustAuthenticate(tmpl *template.Template, store *session.MemoryStore, authP
s := store.GetByToken(sessionCookie.Value)
if s == nil {
- http.Redirect(w, r, "/auth", http.StatusFound)
+ http.Redirect(w, r, "/auth?error="+url.QueryEscape("Session does not exist"), http.StatusFound)
return
}
err = authProvider.UpdateUserInfo(r.Context(), s)
if err != nil {
if errors.Is(err, auth.ErrInvalidToken) {
- http.Redirect(w, r, "/auth", http.StatusFound)
+ http.Redirect(w, r, "/auth?error="+url.QueryEscape("OIDC authentication has expired"), http.StatusFound)
return
}
slog.Error("error updating user info", "cause", err)