Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: added tests to the account domain #993

Merged
merged 5 commits into from
Nov 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: ensure expiration comes from same value
fmartingr committed Oct 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c6345ba3f206ebfe73b035f18e357d65b8a8913d
12 changes: 7 additions & 5 deletions internal/http/routes/api/v1/auth.go
Original file line number Diff line number Diff line change
@@ -81,18 +81,20 @@ func (r *AuthAPIRoutes) loginHandler(c *gin.Context) {
return
}

expiration := time.Now().Add(time.Hour)
expiration := time.Hour
if payload.RememberMe {
expiration = time.Now().Add(time.Hour * 24 * 30)
expiration = time.Hour * 24 * 30
}

token, err := r.deps.Domains.Auth.CreateTokenForAccount(account, expiration)
expirationTime := time.Now().Add(expiration)

token, err := r.deps.Domains.Auth.CreateTokenForAccount(account, expirationTime)
if err != nil {
response.SendInternalServerError(c)
return
}

sessionID, err := r.legacyLoginHandler(*account, time.Hour*24*30)
sessionID, err := r.legacyLoginHandler(*account, expiration)
if err != nil {
r.logger.WithError(err).Error("failed execute legacy login handler")
response.SendInternalServerError(c)
@@ -102,7 +104,7 @@ func (r *AuthAPIRoutes) loginHandler(c *gin.Context) {
response.Send(c, http.StatusOK, loginResponseMessage{
Token: token,
SessionID: sessionID,
Expiration: expiration.Unix(),
Expiration: expirationTime.Unix(),
})
}