From 19991e29472d756cdb5f34a8c4e473ea1aca35bc Mon Sep 17 00:00:00 2001 From: Mark Bailey Date: Tue, 26 Nov 2024 08:52:58 -0500 Subject: [PATCH] refactor: move code so it's a little more organized --- handlers/shared/user.go | 76 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/handlers/shared/user.go b/handlers/shared/user.go index ca38284..7baa940 100644 --- a/handlers/shared/user.go +++ b/handlers/shared/user.go @@ -16,31 +16,6 @@ import ( "git.markbailey.dev/cerbervs/ptpp/view/user" ) -type SignUpHandler struct { - controller.Controller -} - -func (c SignUpHandler) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx controller.IControllerCtx) controller.IController { - c.Logger = l - c.Db = d - c.Session = s - c.Ctx = ctx - - return c -} - -type SignInHandler struct { - controller.Controller -} - -func (c SignInHandler) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx controller.IControllerCtx) controller.IController { - c.Logger = l - c.Db = d - c.Session = s - - return c -} - type PopulateHandler struct { controller.Controller } @@ -54,19 +29,6 @@ func (c PopulateHandler) Init(s session.IManager, d database.IDB, l logger.ILogg return c } -type SignOutHandler struct { - controller.Controller -} - -func (c SignOutHandler) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx controller.IControllerCtx) controller.IController { - c.Logger = l - c.Db = d - c.Session = s - c.Ctx = ctx - - return c -} - func (c PopulateHandler) Get(w http.ResponseWriter, r *http.Request) error { existingOrg, err := c.Db.Repo().FindOrganizationByName("CerbervsSoft") if existingOrg != nil && err == nil { @@ -96,6 +58,18 @@ func (c PopulateHandler) Get(w http.ResponseWriter, r *http.Request) error { return util.Redirect(w, r, c.Ctx.GetRouteByName("app.user.sign_up"), http.StatusSeeOther, false) } +type SignInHandler struct { + controller.Controller +} + +func (c SignInHandler) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx controller.IControllerCtx) controller.IController { + c.Logger = l + c.Db = d + c.Session = s + + return c +} + type UserSignInForm struct { Username string `json:"username"` Password string `json:"password"` @@ -214,6 +188,19 @@ func (c SignInHandler) Post(w http.ResponseWriter, r *http.Request) error { } } +type SignUpHandler struct { + controller.Controller +} + +func (c SignUpHandler) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx controller.IControllerCtx) controller.IController { + c.Logger = l + c.Db = d + c.Session = s + c.Ctx = ctx + + return c +} + type UserSignUpForm struct { Name string `json:"name"` Email string `json:"email"` @@ -328,6 +315,19 @@ func (c SignUpHandler) Post(w http.ResponseWriter, r *http.Request) error { return nil } +type SignOutHandler struct { + controller.Controller +} + +func (c SignOutHandler) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx controller.IControllerCtx) controller.IController { + c.Logger = l + c.Db = d + c.Session = s + c.Ctx = ctx + + return c +} + func (c SignOutHandler) Get(w http.ResponseWriter, r *http.Request) error { sess := c.Session.SessionStart(w, r)