diff --git a/cmd/backend/config.yaml b/cmd/backend/config.yaml
index f2e060c..d5df5f4 100644
--- a/cmd/backend/config.yaml
+++ b/cmd/backend/config.yaml
@@ -1,5 +1,5 @@
port: 8080
postgres_url: "postgres://postgres:postgres@localhost:5432/postgres"
-jwt_signing_key: "./config_defaults/jwt_signing_key"
+jwt_signing_key: "./jwt_signing_key"
kafka_url: "localhost:9092"
kafka_topic: "backend_events"
\ No newline at end of file
diff --git a/cmd/backend/server/handlers/user_verify_handler.go b/cmd/backend/server/handlers/user_verify_handler.go
new file mode 100644
index 0000000..926ff83
--- /dev/null
+++ b/cmd/backend/server/handlers/user_verify_handler.go
@@ -0,0 +1,51 @@
+package handlers
+
+import (
+ "backend/internal/core/services"
+ "backend/pkg/logger"
+
+ "github.com/gin-gonic/gin"
+)
+
+type A struct {
+ Title string
+ Text string
+ Link string
+ LinkText string
+}
+
+func NewUserVerifyEmailHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
+ htmlOk := `
+
+
+ Verify Email
+
+
+ Email successfuly verified
+
+
+ `
+
+ htmlNotOk := `
+ Verify Email
+ Email was not verified
+
+ `
+
+ return func(c *gin.Context) {
+ token, ok := c.GetQuery("token")
+ if !ok || token == "" {
+ c.Data(400, "text/html", []byte(htmlNotOk))
+ return
+ }
+
+ err := userService.VerifyEmail(c, token)
+ if err != nil {
+ log.Error().Err(err).Msg("Error verifying email")
+ c.Data(400, "text/html", []byte(htmlNotOk))
+ return
+ }
+
+ c.Data(200, "text/html", []byte(htmlOk))
+ }
+}
diff --git a/cmd/backend/server/server.go b/cmd/backend/server/server.go
index 6e13757..68e0ec0 100644
--- a/cmd/backend/server/server.go
+++ b/cmd/backend/server/server.go
@@ -39,17 +39,21 @@ func NewServer(opts NewServerOpts) *httpserver.Server {
r.Use(httpserver.NewRequestLogMiddleware(opts.Logger, opts.Tracer, prometheus))
r.Use(httpserver.NewTracingMiddleware(opts.Tracer))
- v1 := r.Group("/v1")
+ r.GET("/verify-user", handlers.NewUserVerifyEmailHandler(opts.Logger, opts.UserService))
+ api := r.Group("/api")
+
+ v1 := api.Group("/v1")
userGroup := v1.Group("/user")
{
userGroup.POST("/create", handlers.NewUserCreateHandler(opts.Logger, opts.UserService))
userGroup.POST("/login", handlers.NewUserLoginHandler(opts.Logger, opts.UserService))
+
}
dummyGroup := v1.Group("/dummy")
+ dummyGroup.Use(middleware.NewAuthMiddleware(opts.UserService))
{
- dummyGroup.Use(middleware.NewAuthMiddleware(opts.UserService))
dummyGroup.GET("", handlers.NewDummyHandler())
dummyGroup.POST("/forgot-password", func(c *gin.Context) {
user := utils.GetUserFromRequest(c)
diff --git a/internal/core/repos/action_token.go b/internal/core/repos/action_token.go
index 9b4c24a..7eda5f0 100644
--- a/internal/core/repos/action_token.go
+++ b/internal/core/repos/action_token.go
@@ -50,7 +50,7 @@ func (a *actionTokenRepo) GetActionToken(ctx context.Context, value string, targ
query := `
select id, user_id from action_tokens
where
- value=$2 and target=$3
+ value=$1 and target=$2
and CURRENT_TIMESTAMP < expiration;`
row := a.db.QueryRowContext(ctx, query, value, target)
@@ -67,7 +67,7 @@ func (a *actionTokenRepo) GetActionToken(ctx context.Context, value string, targ
func (a *actionTokenRepo) DeleteActionToken(ctx context.Context, id string) error {
query := `delete from action_tokens where id=$1;`
- if _, err := a.db.ExecContext(ctx, query); err != nil {
+ if _, err := a.db.ExecContext(ctx, query, id); err != nil {
return err
}
return nil