Skip to content

Commit

Permalink
fix wrong timestamp in email token (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu authored Dec 7, 2024
2 parents 8c5a785 + 2615124 commit 6ecc795
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/internal/server/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ func (s *Server) handleSignup(c echo.Context) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
q := db.New(pool)
exp := time.Now().Add(time.Minute * 30)
token, err := q.CreateVerifyEmailToken(ctx, db.CreateVerifyEmailTokenParams{
Email: email,
// default expires after 30 minutes
ExpiresAt: time.Now().Add(time.Minute * 30),
ExpiresAt: exp,
})
if err != nil {
log.Error().Err(err).Str("email", email).Msg("Failed to create verify email token in db.")
return
}
tokenStr, err := jwt.GenerateVerifyEmailToken(email, token.ID, token.ExpiresAt)
tokenStr, err := jwt.GenerateVerifyEmailToken(email, token.ID, exp)
if err != nil {
log.Error().Err(err).Str("email", email).Msg("Failed to generate signed verify email token.")
return
Expand Down Expand Up @@ -226,6 +227,7 @@ func (s *Server) handleVerifyEmail(c echo.Context) error {
"success": true,
})
}

/*
handleEmailVerifiedStatus checks for the email_verified column of the given email.
If the email does not exist in the users table, it returns false. The same goes
Expand Down

0 comments on commit 6ecc795

Please sign in to comment.