Add multi language support for authentication middleware

This commit is contained in:
Achim Rohn
2025-09-17 18:05:23 +02:00
parent 667345bc9e
commit f70a4ad777
10 changed files with 182 additions and 10 deletions
+13 -1
View File
@@ -9,6 +9,7 @@ import (
"ersteller-lib/starter/env"
"ersteller-lib/starter/google"
"ersteller-lib/starter/index"
"ersteller-lib/starter/login"
"ersteller-lib/starter/page"
"net/http"
@@ -69,9 +70,20 @@ func CreateApi(environment env.Environment, db *ent.Client) http.Handler {
_ = about.NewPage(createPageFunc, server, &aboutActivePath)
_ = contact.NewPage(createPageFunc, server, &contactActivePath)
// Create Login page
loginPaths := LanguagePaths{
En: login.LoginPath,
De: login.LoginPathDe,
}
loginActivePath := NewActivePath(map[Language]string{
En: "Login",
De: "Anmelden",
}, loginPaths)
_ = login.NewPage(createPageFunc, server, &loginActivePath)
serverWithMiddleWare := UseMiddleware(server, LoggingMiddleware, MakeGzipHandler,
authentication.Middleware(sessionStore,
[]string{"/login", google.GoogleLogin, google.GoogleLoginCallback}, "/"))
[]string{"/de" + login.LoginPathDe, "/en" + authentication.LoginPath, google.GoogleLogin, google.GoogleLoginCallback, "/static"}, loginPaths))
return serverWithMiddleWare
}