From 2d2a8248c496bf04ef3ffb26485cb2ed6a484ed3 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 25 Feb 2026 16:09:10 +0000 Subject: [PATCH] Add required config to signin context --- html/template/sync/signin.html | 4 ++-- sync/routes.go | 3 ++- sync/signin.go | 22 ++++++++++++++++------ sync/url.go | 6 +++--- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/html/template/sync/signin.html b/html/template/sync/signin.html index 17100657..c816d7ce 100644 --- a/html/template/sync/signin.html +++ b/html/template/sync/signin.html @@ -38,7 +38,7 @@
- +
- {{ if .InvalidCredentials }} + {{ if .C.InvalidCredentials }} diff --git a/sync/routes.go b/sync/routes.go index 706a3eab..1ea8991b 100644 --- a/sync/routes.go +++ b/sync/routes.go @@ -127,7 +127,7 @@ type contentAuthenticated[T any] struct { C T Config contentConfig Organization *models.Organization - URL ContentURL + URL contentURL User User } @@ -158,6 +158,7 @@ func authenticatedHandler[T any](f handlerFunctionGet[T]) http.Handler { } html.RenderOrError(w, resp.template, contentAuthenticated[T]{ C: resp.content, + Config: newContentConfig(), Organization: org, URL: newContentURL(), User: userContent, diff --git a/sync/signin.go b/sync/signin.go index 4b013af9..479a310e 100644 --- a/sync/signin.go +++ b/sync/signin.go @@ -12,11 +12,11 @@ import ( "github.com/rs/zerolog/log" ) -type ContentSignin struct { +type contentSignin struct { InvalidCredentials bool Next string } -type ContentSignup struct{} +type contentSignup struct{} func getSignin(w http.ResponseWriter, r *http.Request) { errorCode := r.URL.Query().Get("error") @@ -30,7 +30,7 @@ func getSignout(w http.ResponseWriter, r *http.Request, user *models.User) { } func getSignup(w http.ResponseWriter, r *http.Request) { - data := ContentSignup{} + data := contentSignup{} html.RenderOrError(w, "sync/signup.html", data) } @@ -96,13 +96,23 @@ func postSignup(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/", http.StatusFound) } +type contentUnauthenticated[T any] struct { + C T + Config contentConfig + URL contentURL +} + func signin(w http.ResponseWriter, errorCode string, next string) { if next == "" { next = "/" } - data := ContentSignin{ - InvalidCredentials: errorCode == "invalid-credentials", - Next: next, + data := contentUnauthenticated[contentSignin]{ + C: contentSignin{ + InvalidCredentials: errorCode == "invalid-credentials", + Next: next, + }, + Config: newContentConfig(), + URL: newContentURL(), } html.RenderOrError(w, "sync/signin.html", data) } diff --git a/sync/url.go b/sync/url.go index 7ca2bff8..e034bdd4 100644 --- a/sync/url.go +++ b/sync/url.go @@ -4,7 +4,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/config" ) -type ContentURL struct { +type contentURL struct { OAuthRefreshArcGIS string Root string Route string @@ -20,8 +20,8 @@ type ContentURL struct { UploadCSVPool string } -func newContentURL() ContentURL { - return ContentURL{ +func newContentURL() contentURL { + return contentURL{ OAuthRefreshArcGIS: config.MakeURLNidus("/arcgis/oauth/begin"), Root: config.MakeURLNidus("/"), Route: config.MakeURLNidus("/route"),