Skip to content

Commit 20b83b4

Browse files
chore: log when attempted password resets fail
1 parent 4e20eea commit 20b83b4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

coderd/userauth.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ func (api *API) postRequestOneTimePasscode(rw http.ResponseWriter, r *http.Reque
291291
if err != nil {
292292
logger.Error(ctx, "unable to notify user about one-time passcode request", slog.Error(err))
293293
}
294+
} else {
295+
logger.Warn(ctx, "password reset requested for account that does not exist", slog.F("email", req.Email))
294296
}
295297
}
296298

@@ -381,6 +383,7 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
381383

382384
now := dbtime.Now()
383385
if !equal || now.After(user.OneTimePasscodeExpiresAt.Time) {
386+
logger.Warn(ctx, "password reset attempted with invalid one-time passcode", slog.F("email", req.Email))
384387
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
385388
Message: "Incorrect email or one-time passcode.",
386389
})

0 commit comments

Comments
 (0)