Add required config to signin context

This commit is contained in:
Eli Ribble 2026-02-25 16:09:10 +00:00
parent 2bb4a134b2
commit 2d2a8248c4
No known key found for this signature in database
4 changed files with 23 additions and 12 deletions

View file

@ -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,

View file

@ -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)
}

View file

@ -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"),