activity: implement most initial logging

resetPassword, changePassword, delete/createInvite, enable/disable,
creation/deletion of invites & users are all done, only remaining one is
account linking.
This commit is contained in:
Harvey Tindall
2023-10-19 18:56:35 +01:00
parent 2c787b4d46
commit b620c0d9ae
7 changed files with 120 additions and 4 deletions
+17
View File
@@ -17,6 +17,7 @@ import (
"github.com/golang-jwt/jwt"
"github.com/gomarkdown/markdown"
"github.com/hrfee/mediabrowser"
"github.com/lithammer/shortuuid/v3"
"github.com/steambap/captcha"
)
@@ -329,6 +330,7 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
}
username = pwr.Username
}
if (status == 200 || status == 204) && err == nil && (isInternal || resp.Success) {
data["success"] = true
data["pin"] = pin
@@ -338,6 +340,21 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
} else {
app.err.Printf("Password Reset failed (%d): %v", status, err)
}
// Only log PWRs we know the user for.
if username != "" {
jfUser, status, err := app.jf.UserByName(username, false)
if err == nil && status == 200 {
app.storage.SetActivityKey(shortuuid.New(), Activity{
Type: ActivityResetPassword,
UserID: jfUser.ID,
SourceType: ActivityUser,
Source: jfUser.ID,
Time: time.Now(),
})
}
}
if app.config.Section("ombi").Key("enabled").MustBool(false) {
jfUser, status, err := app.jf.UserByName(username, false)
if status != 200 || err != nil {