Dev#2
Open
BruceGoodGuy wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR wires up a basic user registration + email confirmation + authentication flow in the Go app, adds an HTML verification email template, introduces Redis Bloom-filter–based email existence checks, and updates Redis/rate-limit infrastructure to support that flow.
Changes:
- Added verification email templating and updated the mail sender to render HTML templates.
- Implemented user registration staging in Redis + confirmation endpoint + JWT auth flow (with refresh tokens stored in Redis).
- Switched Redis client to
github.com/redis/go-redis/v9, introduced Bloom filter seeding on startup, and updated Docker Compose to Redis Stack.
Reviewed changes
Copilot reviewed 16 out of 20 changed files in this pull request and generated 23 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds a placeholder README line. |
| go-app/tmp/build-errors.log | Removes a tracked build error log. |
| go-app/templates/verify.html | Adds the HTML verification email template. |
| go-app/pkg/mail/gomail.go | Updates mail sender to render and send HTML templates. |
| go-app/pkg/cache/redis.go | Migrates Redis client import to go-redis v9. |
| go-app/internal/user/service.go | Adds auth/token logic and user service methods. |
| go-app/internal/user/repository.go | Adds staged registration in Redis, Bloom filter seeding/checks, confirmation, refresh-token storage. |
| go-app/internal/user/model.go | Adds a secondary user struct type. |
| go-app/internal/user/handler.go | Adds verify/confirm/auth endpoints and additional request handling. |
| go-app/internal/user/dto.go | Adds DTOs for verify/confirm/auth flows. |
| go-app/internal/test/repository.go | Migrates Redis client import to go-redis v9. |
| go-app/internal/middleware/rate_limit.go | Makes rate limiting configurable and constructs limiter store/client. |
| go-app/internal/app/application.go | Injects mail into user repo, adds Bootstrap seeding, updates routes + rate limits. |
| go-app/go.mod | Updates dependencies (JWT, validator, go-redis v9, limiter). |
| go-app/go.sum | Updates dependency checksums. |
| go-app/cmd/api/main.go | Calls application bootstrap before routes. |
| docker-compose.yml | Switches Redis image to redis-stack-server. |
| .gitignore | Ignores go-app/tmp/. |
| .github/instructions/review.instructions.md | Adds repository code review standards/instructions. |
Comments suppressed due to low confidence (2)
go-app/internal/middleware/rate_limit.go:23
- RateLimit creates a brand-new Redis client (and does a Ping) every time the middleware is constructed, which happens multiple times in Routes(). This wastes connections and increases startup latency; inject a shared Redis client/store into the middleware instead of calling cache.Connect() here.
func RateLimit(numberRequest int, period string) gin.HandlerFunc {
rate, err := limiter.NewRateFromFormatted(fmt.Sprintf("%d-%s", numberRequest, period))
if err != nil {
panic(err)
}
client := cache.Connect()
store, err := redis.NewStore(client)
go-app/internal/middleware/rate_limit.go:26
- This middleware panics on rate parsing/store creation errors. Panics crash the server and are hard to operate; prefer returning an error during app startup (and failing fast with a clear error) rather than panicking from inside middleware construction.
func RateLimit(numberRequest int, period string) gin.HandlerFunc {
rate, err := limiter.NewRateFromFormatted(fmt.Sprintf("%d-%s", numberRequest, period))
if err != nil {
panic(err)
}
client := cache.Connect()
store, err := redis.NewStore(client)
if err != nil {
panic(err)
}
| @@ -0,0 +1 @@ | |||
| comming soon.... really soonnnnnnn | |||
|
|
||
| <p style="color: #636e72; font-size: 17px; line-height: 1.8; margin: 0 0 30px 0;"> | ||
| Your journey to finding the best flavors starts here. We're thrilled to have another | ||
| **Food Lover** join our community! To start exploring nearby eats and hidden gems, |
Comment on lines
7
to
+11
| "log" | ||
| "os" | ||
| "path/filepath" | ||
| "strconv" | ||
| "text/template" |
Comment on lines
+50
to
+56
| // 1. Build the path to the template file | ||
| // The templates are located in the "templates" folder at the project root | ||
| templatePath := filepath.Join("templates", templateName+".html") | ||
|
|
||
| // 2. Parse and execute the HTML template | ||
| tmpl, err := template.ParseFiles(templatePath) | ||
| if err != nil { |
Comment on lines
+57
to
+59
|
|
||
| fmt.Print(token.AccessToken) | ||
|
|
Comment on lines
+86
to
+87
| accessTokenString, err := accessToken.SignedString([]byte(os.Getenv("SECRET_STRING"))) | ||
| if err != nil { |
Comment on lines
+172
to
+177
| defer func() { | ||
| if r := recover(); r != nil { | ||
| fmt.Printf("[ActivateAccount] DB error, Can't activate account: %v", r) | ||
| } | ||
| }() | ||
|
|
Comment on lines
+118
to
+119
| r.cache.Set(ctx, "register:email:"+u.Email, key, ttl) | ||
| r.cache.Set(ctx, "register:token:"+key, string(jsonData), ttl) |
Comment on lines
+68
to
+72
| ctx.JSON(http.StatusInternalServerError, response.Response{ | ||
| IsSuccess: false, | ||
| Message: "Failed to create user", | ||
| Data: err.Error(), | ||
| }) |
Comment on lines
+57
to
+60
| if isExist, err := h.s.VerifyEmailExist(ctx, user.Email, false); err == nil { | ||
| if isExist { | ||
| ctx.JSON(http.StatusUnprocessableEntity, response.Response{IsSuccess: false, Message: "Duplicate email"}) | ||
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.