Skip to content

Commit

Permalink
fix: update audit log events for phone change
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Feb 7, 2024
1 parent 80e0262 commit fc2554b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,21 @@ func (a *API) smsVerify(r *http.Request, ctx context.Context, conn *storage.Conn
config := a.config

err := conn.Transaction(func(tx *storage.Connection) error {
if terr := models.NewAuditLogEntry(r, tx, user, models.UserSignedUpAction, "", nil); terr != nil {
return terr
}

if terr := triggerEventHooks(ctx, tx, SignupEvent, user, config); terr != nil {
return terr
}

if params.Type == smsVerification {
if terr := models.NewAuditLogEntry(r, tx, user, models.UserSignedUpAction, "", nil); terr != nil {
return terr
}
if terr := user.ConfirmPhone(tx); terr != nil {
return internalServerError("Error confirming user").WithInternalError(terr)
}
} else if params.Type == phoneChangeVerification {
if terr := models.NewAuditLogEntry(r, tx, user, models.UserModifiedAction, "", nil); terr != nil {
return terr
}
if identity, terr := models.FindIdentityByIdAndProvider(tx, user.ID.String(), "phone"); terr != nil {
if !models.IsNotFoundError(terr) {
return terr
Expand Down

0 comments on commit fc2554b

Please sign in to comment.