6 files changed,
20 insertions(+),
23 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2025-05-21 17:01:56 +0300
Parent:
218bb4e
M
cmd/server/main.go
··· 158 158 } 159 159 160 160 // graceful shutdown 161 - quit := make(chan os.Signal, 1) 162 - signal.Notify(quit, os.Interrupt) 163 - <-quit 161 + quitCh := make(chan os.Signal, 1) 162 + signal.Notify(quitCh, os.Interrupt) 163 + <-quitCh 164 164 165 165 if err := srv.Stop(ctx); err != nil { 166 166 return errors.Join(errors.New("failed to stop http server"), err)
M
internal/service/usersrv/usersrv.go
··· 118 118 } 119 119 120 120 verificationToken := uuid.Must(uuid.NewV4()).String() 121 - if err := u.vertokrepo.Create( 122 - ctx, 123 - verificationToken, 124 - userID, 125 - time.Now(), 126 - time.Now().Add(u.verificationTokenTTL), 127 - ); err != nil { 121 + if err := u.vertokrepo.Create(ctx, models.VerificationToken{ 122 + UserID: userID, 123 + Token: verificationToken, 124 + CreatedAt: time.Now(), 125 + ExpiresAt: time.Now().Add(u.verificationTokenTTL), 126 + }); err != nil { 128 127 return uuid.Nil, err 129 128 } 130 129
M
internal/store/psql/vertokrepo/vertokrepo.go
··· 11 11 ) 12 12 13 13 type VerificationTokenStorer interface { 14 - Create( 15 - ctx context.Context, 16 - token string, 17 - userID uuid.UUID, 18 - createdAt, expiresAt time.Time, 19 - ) error 14 + Create(ctx context.Context, token models.VerificationToken) error 20 15 21 16 GetUserIDByTokenAndMarkAsUsed( 22 17 ctx context.Context, ··· 46 41 47 42 func (r *VerificationTokenRepo) Create( 48 43 ctx context.Context, 49 - token string, 50 - userID uuid.UUID, 51 - createdAt, expiresAt time.Time, 44 + token models.VerificationToken, 52 45 ) error { 53 46 query, aggs, err := pgq. 54 47 Insert("verification_tokens"). 55 48 Columns("user_id", "token", "created_at", "expires_at"). 56 - Values(userID, token, createdAt, expiresAt). 49 + Values(token.UserID, token.Token, token.CreatedAt, token.ExpiresAt). 57 50 SQL() 58 51 if err != nil { 59 52 return err