fix: do 2FA on OpenID connect

This commit is contained in:
Gusted 2025-08-22 23:17:22 +02:00 committed by Earl Warren
commit 90e974cd24
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
6 changed files with 79 additions and 16 deletions

View file

@ -40,8 +40,8 @@ func GetUserOpenIDs(ctx context.Context, uid int64) ([]*UserOpenID, error) {
return openids, nil
}
// isOpenIDUsed returns true if the openid has been used.
func isOpenIDUsed(ctx context.Context, uri string) (bool, error) {
// IsOpenIDUsed returns true if the openid has been used.
func IsOpenIDUsed(ctx context.Context, uri string) (bool, error) {
if len(uri) == 0 {
return true, nil
}
@ -71,7 +71,7 @@ func (err ErrOpenIDAlreadyUsed) Unwrap() error {
// AddUserOpenID adds an pre-verified/normalized OpenID URI to given user.
// NOTE: make sure openid.URI is normalized already
func AddUserOpenID(ctx context.Context, openid *UserOpenID) error {
used, err := isOpenIDUsed(ctx, openid.URI)
used, err := IsOpenIDUsed(ctx, openid.URI)
if err != nil {
return err
} else if used {