Skip to content

Commit

Permalink
fix: adjust names
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Sep 30, 2024
1 parent ae4d856 commit dabd447
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ func (a *API) enrollTOTPFactor(w http.ResponseWriter, r *http.Request, params *E
}

if err := db.Load(user, "Factors"); err != nil {
return fmt.Errorf("failed to reload user factors: %w", err)
return err
}

if err := validateFactors(user, params.FriendlyName, config, session); err != nil {
return err
}
Expand Down Expand Up @@ -222,8 +221,8 @@ func (a *API) enrollTOTPFactor(w http.ResponseWriter, r *http.Request, params *E
err = db.Transaction(func(tx *storage.Connection) error {
if terr := tx.Create(factor); terr != nil {
return terr

}

if terr := models.NewAuditLogEntry(r, tx, user, models.EnrollFactorAction, r.RemoteAddr, map[string]interface{}{
"factor_id": factor.ID,
}); terr != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/mfa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (ts *MFATestSuite) TestMultipleEnrollsCleanupExpiredFactors() {
_ = performChallengeFlow(ts, enrollResp.ID, token)

// Enroll another Factor (Factor 3)
_ = performEnrollFlow(ts, token, "", models.TOTP, "https://issuer.com", "", http.StatusOK)
_ = performEnrollFlow(ts, token, "non-empty-names", models.TOTP, "https://issuer.com", "", http.StatusOK)
require.NoError(ts.T(), ts.API.db.Eager("Factors").Find(ts.TestUser, ts.TestUser.ID))
require.Equal(ts.T(), 3, len(ts.TestUser.Factors))
}
Expand Down
1 change: 1 addition & 0 deletions internal/models/factor.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func ParseAuthenticationMethod(authMethod string) (AuthenticationMethod, error)

type Factor struct {
ID uuid.UUID `json:"id" db:"id"`
User User `json:"-" belongs_to:"user"`
UserID uuid.UUID `json:"-" db:"user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
Expand Down

0 comments on commit dabd447

Please sign in to comment.