diff --git a/adapters/secondary/gateways/web/templates/componentNavbar.html b/adapters/secondary/gateways/web/templates/componentNavbar.html
index 155581f..88e8714 100644
--- a/adapters/secondary/gateways/web/templates/componentNavbar.html
+++ b/adapters/secondary/gateways/web/templates/componentNavbar.html
@@ -23,9 +23,6 @@
- -
- support me!
-
-
Log out
diff --git a/api/controllers/auth/auth.go b/api/controllers/auth/auth.go
index 1d24f41..069d514 100644
--- a/api/controllers/auth/auth.go
+++ b/api/controllers/auth/auth.go
@@ -11,7 +11,6 @@ import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/jwtauth/v5"
- "github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
)
@@ -102,19 +101,6 @@ func GetUserFromCredentials(credentials LoginCredentials) (user.User, error) {
return dbUser, nil
}
-func GetNewUser(newUserCredentials RegisterCredentials, verificationCode string) (user.User, error) {
- createdUser, err := api.Container.CreateUserUseCase.CreateUser(useCases.CreateUserCommand{
- Username: newUserCredentials.Username,
- Password: newUserCredentials.Password,
- Email: newUserCredentials.Email,
- VerificationCode: verificationCode,
- })
- if err != nil {
- return user.User{}, err
- }
- return createdUser, nil
-}
-
func login(w http.ResponseWriter, r *http.Request) {
var credentials LoginCredentials
@@ -161,8 +147,11 @@ func register(w http.ResponseWriter, r *http.Request) {
return
}
- verificationCode := uuid.NewString()
- createdUser, err := GetNewUser(credentials, verificationCode)
+ createdUser, err := api.Container.CreateUserUseCase.CreateUser(useCases.CreateUserCommand{
+ Username: credentials.Username,
+ Password: credentials.Password,
+ Email: credentials.Email,
+ })
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/api/controllers/pages/register.go b/api/controllers/pages/register.go
index cc77245..2ac5163 100644
--- a/api/controllers/pages/register.go
+++ b/api/controllers/pages/register.go
@@ -3,10 +3,9 @@ package pages
import (
"RenewCMS/api"
"RenewCMS/api/controllers/auth"
+ "RenewCMS/useCases"
"net/http"
"os"
-
- "github.com/google/uuid"
)
type RegisterPageError struct {
@@ -80,8 +79,11 @@ func PostRegisterPage(w http.ResponseWriter, r *http.Request) {
return
}
- verificationCode := uuid.NewString()
- createdUser, err := auth.GetNewUser(credentials, verificationCode)
+ createdUser, err := api.Container.CreateUserUseCase.CreateUser(useCases.CreateUserCommand{
+ Username: credentials.Username,
+ Password: credentials.Password,
+ Email: credentials.Email,
+ })
if err != nil {
r.Method = http.MethodGet
GetRegisterPageHandler(&RegisterPage{
@@ -98,7 +100,7 @@ func PostRegisterPage(w http.ResponseWriter, r *http.Request) {
_ = api.Container.SendMailUseCase.SendMail(createdUser.Email, "mailValidation", map[string]string{
"Host": os.Getenv("HOST"),
- "VerificationCode": verificationCode,
+ "VerificationCode": createdUser.VerificationCode,
})
_ = auth.SetJwtCookie(&w, createdUser.ID)
diff --git a/useCases/CreateUser.go b/useCases/CreateUser.go
index f8a47af..c87fd45 100644
--- a/useCases/CreateUser.go
+++ b/useCases/CreateUser.go
@@ -3,6 +3,8 @@ package useCases
import (
"RenewCMS/domain/gateways"
"RenewCMS/domain/user"
+
+ "github.com/google/uuid"
)
type CreateUserUseCase struct {
@@ -10,10 +12,9 @@ type CreateUserUseCase struct {
}
type CreateUserCommand struct {
- Username string
- Password string
- Email string
- VerificationCode string
+ Username string
+ Password string
+ Email string
}
func NewCreateUserUseCase(userRepository gateways.IUserRepository) *CreateUserUseCase {
@@ -26,6 +27,6 @@ func (g *CreateUserUseCase) CreateUser(createUser CreateUserCommand) (user.User,
createUser.Password,
"",
createUser.Email,
- createUser.VerificationCode,
+ uuid.NewString(),
))
}