refactor: move code so it's a little more organized
This commit is contained in:
parent
15abbde592
commit
19991e2947
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user