Add multi language support for authentication middleware
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user