Skip to content

Commit

Permalink
allow tfa to be disabled without removing the settings (#422)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade authored Jan 28, 2025
1 parent c03a18b commit d0b1069
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions internal/ent/hooks/usersettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/generated/hook"
"github.com/theopenlane/core/internal/ent/generated/privacy"
"github.com/theopenlane/core/internal/ent/generated/tfasetting"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/usersetting"
"github.com/theopenlane/core/internal/ent/privacy/rule"
Expand All @@ -29,20 +28,6 @@ func HookUserSetting() ent.Hook {
return nil, rout.InvalidField(rout.ErrOrganizationNotFound)
}

// delete tfa setting if tfa is disabled
tfaEnabled, ok := m.IsTfaEnabled()
if ok && !tfaEnabled {
userID, err := auth.GetUserIDFromContext(ctx)
if err != nil {
return nil, err
}

_, err = m.Client().TFASetting.Delete().Where(tfasetting.OwnerID(userID)).Exec(ctx)
if err != nil {
return nil, err
}
}

return next.Mutate(ctx, m)
})
}, ent.OpUpdate|ent.OpUpdateOne)
Expand Down

0 comments on commit d0b1069

Please sign in to comment.