all repos

onasty @ 35adc6e9860d31ca1173560bcdb18464c9187ac8

a one-time notes service
4 files changed, 9 insertions(+), 7 deletions(-)
refactor: dont break code consitency (#23)

* refactor: don't pass userID though dto

* chore(Taskfile): disable caching for e2e tests
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
        33
             - go test -v --short ./...

      
        34
        34
         

      
        35
        35
           test:e2e:

      
        36
        
        -    - go test -v ./e2e/

      
        
        36
        +    - go test --count=1 -v ./e2e/

      
M internal/dtos/user.go
···
        17
        17
         }

      
        18
        18
         

      
        19
        19
         type ResetUserPasswordDTO struct {

      
        20
        
        -	// NOTE: probably userID shouldn't be here

      
        21
        
        -	UserID          uuid.UUID

      
        22
        20
         	CurrentPassword string

      
        23
        21
         	NewPassword     string

      
        24
        22
         }

      
M internal/service/usersrv/usersrv.go
···
        22
        22
         	RefreshTokens(ctx context.Context, refreshToken string) (dtos.TokensDTO, error)

      
        23
        23
         	Logout(ctx context.Context, userID uuid.UUID) error

      
        24
        24
         

      
        25
        
        -	ChangePassword(ctx context.Context, inp dtos.ResetUserPasswordDTO) error

      
        
        25
        +	ChangePassword(ctx context.Context, userID uuid.UUID, inp dtos.ResetUserPasswordDTO) error

      
        26
        26
         

      
        27
        27
         	Verify(ctx context.Context, verificationKey string) error

      
        28
        28
         	ResendVerificationEmail(ctx context.Context, credentials dtos.SignInDTO) error

      ···
        165
        165
         	}, nil

      
        166
        166
         }

      
        167
        167
         

      
        168
        
        -func (u *UserSrv) ChangePassword(ctx context.Context, inp dtos.ResetUserPasswordDTO) error {

      
        
        168
        +func (u *UserSrv) ChangePassword(

      
        
        169
        +	ctx context.Context,

      
        
        170
        +	userID uuid.UUID,

      
        
        171
        +	inp dtos.ResetUserPasswordDTO,

      
        
        172
        +) error {

      
        169
        173
         	oldPass, err := u.hasher.Hash(inp.CurrentPassword)

      
        170
        174
         	if err != nil {

      
        171
        175
         		return err

      ···
        176
        180
         		return err

      
        177
        181
         	}

      
        178
        182
         

      
        179
        
        -	if err := u.userstore.ChangePassword(ctx, inp.UserID, oldPass, newPass); err != nil {

      
        
        183
        +	if err := u.userstore.ChangePassword(ctx, userID, oldPass, newPass); err != nil {

      
        180
        184
         		return err

      
        181
        185
         	}

      
        182
        186
         

      
M internal/transport/http/apiv1/auth.go
···
        154
        154
         

      
        155
        155
         	if err := a.usersrv.ChangePassword(

      
        156
        156
         		c.Request.Context(),

      
        
        157
        +		a.getUserID(c),

      
        157
        158
         		dtos.ResetUserPasswordDTO{

      
        158
        
        -			UserID:          a.getUserID(c),

      
        159
        159
         			CurrentPassword: req.CurrentPassword,

      
        160
        160
         			NewPassword:     req.NewPassword,

      
        161
        161
         		}); err != nil {