fix: remove redundante names
This commit is contained in:
@@ -13,23 +13,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type HandlerAuth interface {
|
||||
type Auth interface {
|
||||
Handle(router *http.ServeMux)
|
||||
}
|
||||
|
||||
type HandlerAuthImpl struct {
|
||||
service service.AuthService
|
||||
type AuthImpl struct {
|
||||
service service.Auth
|
||||
render *Render
|
||||
}
|
||||
|
||||
func NewHandlerAuth(service service.AuthService, render *Render) HandlerAuth {
|
||||
return HandlerAuthImpl{
|
||||
func NewAuth(service service.Auth, render *Render) Auth {
|
||||
return AuthImpl{
|
||||
service: service,
|
||||
render: render,
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) Handle(router *http.ServeMux) {
|
||||
func (handler AuthImpl) Handle(router *http.ServeMux) {
|
||||
router.Handle("/auth/signin", handler.handleSignInPage())
|
||||
router.Handle("/api/auth/signin", handler.handleSignIn())
|
||||
|
||||
@@ -56,7 +56,7 @@ var (
|
||||
securityWaitDuration = 250 * time.Millisecond
|
||||
)
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignInPage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignInPage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, _ := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
if user != nil {
|
||||
@@ -74,7 +74,7 @@ func (handler HandlerAuthImpl) handleSignInPage() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignIn() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignIn() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := utils.WaitMinimumTime(securityWaitDuration, func() (*service.User, error) {
|
||||
var email = r.FormValue("email")
|
||||
@@ -119,7 +119,7 @@ func (handler HandlerAuthImpl) handleSignIn() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignUpPage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignUpPage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, _ := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
|
||||
@@ -137,7 +137,7 @@ func (handler HandlerAuthImpl) handleSignUpPage() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignUpVerifyPage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignUpVerifyPage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, _ := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
if user == nil {
|
||||
@@ -155,7 +155,7 @@ func (handler HandlerAuthImpl) handleSignUpVerifyPage() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleVerifyResendComp() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleVerifyResendComp() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
if err != nil {
|
||||
@@ -172,7 +172,7 @@ func (handler HandlerAuthImpl) handleVerifyResendComp() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignUpVerifyResponsePage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignUpVerifyResponsePage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
token := r.URL.Query().Get("token")
|
||||
@@ -187,7 +187,7 @@ func (handler HandlerAuthImpl) handleSignUpVerifyResponsePage() http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignUp() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignUp() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var email = r.FormValue("email")
|
||||
var password = r.FormValue("password")
|
||||
@@ -217,7 +217,7 @@ func (handler HandlerAuthImpl) handleSignUp() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleSignOut() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleSignOut() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
err := handler.service.SignOut(utils.GetSessionID(r))
|
||||
if err != nil {
|
||||
@@ -241,7 +241,7 @@ func (handler HandlerAuthImpl) handleSignOut() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleDeleteAccountPage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleDeleteAccountPage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// An unverified email should be able to delete their account
|
||||
user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
@@ -254,7 +254,7 @@ func (handler HandlerAuthImpl) handleDeleteAccountPage() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleDeleteAccountComp() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleDeleteAccountComp() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
if err != nil {
|
||||
@@ -280,7 +280,7 @@ func (handler HandlerAuthImpl) handleDeleteAccountComp() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleChangePasswordPage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleChangePasswordPage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
isPasswordReset := r.URL.Query().Has("token")
|
||||
@@ -297,7 +297,7 @@ func (handler HandlerAuthImpl) handleChangePasswordPage() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleChangePasswordComp() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleChangePasswordComp() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
@@ -319,7 +319,7 @@ func (handler HandlerAuthImpl) handleChangePasswordComp() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleResetPasswordPage() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleResetPasswordPage() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r))
|
||||
@@ -333,7 +333,7 @@ func (handler HandlerAuthImpl) handleResetPasswordPage() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleForgotPasswordComp() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleForgotPasswordComp() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
email := r.FormValue("email")
|
||||
@@ -351,7 +351,7 @@ func (handler HandlerAuthImpl) handleForgotPasswordComp() http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (handler HandlerAuthImpl) handleForgotPasswordResponseComp() http.HandlerFunc {
|
||||
func (handler AuthImpl) handleForgotPasswordResponseComp() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
pageUrl, err := url.Parse(r.Header.Get("HX-Current-URL"))
|
||||
|
||||
Reference in New Issue
Block a user