4 files changed,
9 insertions(+),
7 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2024-09-26 22:59:24 +0300
Parent:
2327475
M
Taskfile.yml
@@ -33,4 +33,4 @@ test:unit:
- go test -v --short ./... test:e2e: - - go test -v ./e2e/ + - go test --count=1 -v ./e2e/
M
internal/dtos/user.go
@@ -17,8 +17,6 @@ LastLoginAt time.Time
} type ResetUserPasswordDTO struct { - // NOTE: probably userID shouldn't be here - UserID uuid.UUID CurrentPassword string NewPassword string }
M
internal/service/usersrv/usersrv.go
@@ -22,7 +22,7 @@ SignIn(ctx context.Context, inp dtos.SignInDTO) (dtos.TokensDTO, error)
RefreshTokens(ctx context.Context, refreshToken string) (dtos.TokensDTO, error) Logout(ctx context.Context, userID uuid.UUID) error - ChangePassword(ctx context.Context, inp dtos.ResetUserPasswordDTO) error + ChangePassword(ctx context.Context, userID uuid.UUID, inp dtos.ResetUserPasswordDTO) error Verify(ctx context.Context, verificationKey string) error ResendVerificationEmail(ctx context.Context, credentials dtos.SignInDTO) error@@ -165,7 +165,11 @@ Refresh: tokens.Refresh,
}, nil } -func (u *UserSrv) ChangePassword(ctx context.Context, inp dtos.ResetUserPasswordDTO) error { +func (u *UserSrv) ChangePassword( + ctx context.Context, + userID uuid.UUID, + inp dtos.ResetUserPasswordDTO, +) error { oldPass, err := u.hasher.Hash(inp.CurrentPassword) if err != nil { return err@@ -176,7 +180,7 @@ if err != nil {
return err } - if err := u.userstore.ChangePassword(ctx, inp.UserID, oldPass, newPass); err != nil { + if err := u.userstore.ChangePassword(ctx, userID, oldPass, newPass); err != nil { return err }
M
internal/transport/http/apiv1/auth.go
@@ -154,8 +154,8 @@ }
if err := a.usersrv.ChangePassword( c.Request.Context(), + a.getUserID(c), dtos.ResetUserPasswordDTO{ - UserID: a.getUserID(c), CurrentPassword: req.CurrentPassword, NewPassword: req.NewPassword, }); err != nil {