Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbff384b

Browse files
refactor: error handling
1 parent883a231 commitbff384b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎coderd/userauth.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,13 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
348348
})
349349
iferr!=nil&&!errors.Is(err,sql.ErrNoRows) {
350350
logger.Error(ctx,"unable to fetch user by email",slog.F("email",req.Email),slog.Error(err))
351-
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
352-
Message:"Internal error.",
353-
})
354-
returnnil
351+
returnxerrors.Errorf("get user by email: %w",err)
355352
}
356353
aReq.Old=user
357354

358355
equal,err:=userpassword.Compare(string(user.HashedOneTimePasscode),req.OneTimePasscode)
359356
iferr!=nil {
357+
logger.Error(ctx,"unable to compare one time passcode",slog.Error(err))
360358
returnxerrors.Errorf("compare one time passcode: %w",err)
361359
}
362360

@@ -389,6 +387,7 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
389387

390388
newHashedPassword,err:=userpassword.Hash(req.Password)
391389
iferr!=nil {
390+
logger.Error(ctx,"unable to hash user's password",slog.Error(err))
392391
returnxerrors.Errorf("hash user password: %w",err)
393392
}
394393

@@ -398,12 +397,14 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
398397
HashedPassword: []byte(newHashedPassword),
399398
})
400399
iferr!=nil {
400+
logger.Error(ctx,"unable to delete user's hashed password",slog.Error(err))
401401
returnxerrors.Errorf("update user hashed password: %w",err)
402402
}
403403

404404
//nolint:gocritic // We need the system auth context to be able to delete all API keys for the user.
405405
err=tx.DeleteAPIKeysByUserID(dbauthz.AsSystemRestricted(ctx),user.ID)
406406
iferr!=nil {
407+
logger.Error(ctx,"unable to delete user's api keys",slog.Error(err))
407408
returnxerrors.Errorf("delete api keys for user: %w",err)
408409
}
409410

@@ -418,7 +419,6 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
418419
returnnil
419420
},nil)
420421
iferr!=nil {
421-
logger.Error(ctx,"unable to update user's password",slog.Error(err))
422422
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
423423
Message:"Internal error.",
424424
Detail:err.Error(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp