mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: show audit logs for forgot password flow (#15181)
Fixes https://github.com/coder/coder/issues/15150 Audit logs for requesting a password reset, and a user updating their password, now show up in the audit log.
This commit is contained in:
+3
-1
@@ -220,7 +220,7 @@ func (api *API) postRequestOneTimePasscode(rw http.ResponseWriter, r *http.Reque
|
||||
Audit: *auditor,
|
||||
Log: api.Logger,
|
||||
Request: r,
|
||||
Action: database.AuditActionWrite,
|
||||
Action: database.AuditActionRequestPasswordReset,
|
||||
})
|
||||
)
|
||||
defer commitAudit()
|
||||
@@ -253,6 +253,7 @@ func (api *API) postRequestOneTimePasscode(rw http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
// We continue if err == sql.ErrNoRows to help prevent a timing-based attack.
|
||||
aReq.Old = user
|
||||
aReq.UserID = user.ID
|
||||
|
||||
passcode := uuid.New()
|
||||
passcodeExpiresAt := dbtime.Now().Add(api.OneTimePasscodeValidityPeriod)
|
||||
@@ -365,6 +366,7 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
|
||||
}
|
||||
// We continue if err == sql.ErrNoRows to help prevent a timing-based attack.
|
||||
aReq.Old = user
|
||||
aReq.UserID = user.ID
|
||||
|
||||
equal, err := userpassword.Compare(string(user.HashedOneTimePasscode), req.OneTimePasscode)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user