1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-16 18:01:33 +00:00
forgejo/models/auth/two_factor.go

22 lines
486 B
Go
Raw Normal View History

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package auth
import (
"context"
)
// HasTwoFactorByUID returns true if the user has TOTP or WebAuthn enabled for
// their account.
func HasTwoFactorByUID(ctx context.Context, userID int64) (bool, error) {
hasTOTP, err := HasTOTPByUID(ctx, userID)
if err != nil {
return false, err
}
if hasTOTP {
return true, nil
}
return HasWebAuthnRegistrationsByUID(ctx, userID)
}