Skip to content

Commit

Permalink
Update utils dependency to v0.4.0 and modify token creation to includ…
Browse files Browse the repository at this point in the history
…e expiration duration
  • Loading branch information
L4B0MB4 committed Dec 2, 2024
1 parent 1fb5188 commit d2601c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require github.com/mattn/go-sqlite3 v1.14.24

require (
github.com/L4B0MB4/EVTSRC v0.5.3 // indirect
github.com/PRYVT/utils v0.3.0 // indirect
github.com/PRYVT/utils v0.4.0 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ github.com/PRYVT/utils v0.2.1 h1:GiTbziM3lqRLc4EWGV28+T/aKaY+B80KTqnkBklf9q0=
github.com/PRYVT/utils v0.2.1/go.mod h1:j61GmoyWWXgnCq/laZTIJm4yhD0PreLDMZnYQqjSv7w=
github.com/PRYVT/utils v0.3.0 h1:E0q08Gba+TdIsflKBA2XJLEE/RqbB8u3oXxy1wM7l+s=
github.com/PRYVT/utils v0.3.0/go.mod h1:j61GmoyWWXgnCq/laZTIJm4yhD0PreLDMZnYQqjSv7w=
github.com/PRYVT/utils v0.4.0 h1:RQ7u6sunsic1EfZqOiaZDZvPEJwyx/DlPWqdFlgZHwM=
github.com/PRYVT/utils v0.4.0/go.mod h1:G48oYenFuXUKVVA0sE/lmJlOwHGRacKH/9dNNae0DTk=
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic v1.12.2 h1:oaMFuRTpMHYLpCntGca65YWt5ny+wAceDERTkT2L9lg=
Expand Down
5 changes: 5 additions & 0 deletions pkg/query/eventhandling/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/L4B0MB4/EVTSRC/pkg/models"
"github.com/L4B0MB4/PRYVT/identification/pkg/aggregates"
"github.com/L4B0MB4/PRYVT/identification/pkg/query/store/repository"
"github.com/PRYVT/utils/pkg/interfaces"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
)
Expand All @@ -18,6 +19,10 @@ func NewUserEventHandler(userRepo *repository.UserRepository) *UserEventHandler
}
}

func (eh *UserEventHandler) AddWebsocketConnection(conn interfaces.WebsocketConnecter) {
log.Warn().Msg("Websocket connection not yet supported for user events")
}

func (eh *UserEventHandler) HandleEvent(event models.Event) error {
if event.AggregateType == "user" {
ua, err := aggregates.NewUserAggregate(uuid.MustParse(event.AggregateId))
Expand Down
5 changes: 3 additions & 2 deletions pkg/query/httphandler/controller/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"net/http"
"time"

"github.com/L4B0MB4/PRYVT/identification/pkg/aggregates"
models "github.com/L4B0MB4/PRYVT/identification/pkg/models/query"
Expand Down Expand Up @@ -41,7 +42,7 @@ func (ctrl *UserController) GetToken(c *gin.Context) {
c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
return
}
token, err := auth.CreateToken(userUuid)
token, err := auth.CreateToken(userUuid, 12*time.Hour)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
Expand All @@ -56,7 +57,7 @@ func (ctrl *UserController) RefreshToken(c *gin.Context) {
c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
return
}
token, err := auth.CreateToken(userUuid)
token, err := auth.CreateToken(userUuid, 12*time.Hour)

if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
Expand Down

0 comments on commit d2601c1

Please sign in to comment.