forked from baron/baron-sso
Implement tenant import and RP auto login policies
This commit is contained in:
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"baron-sso-backend/internal/domain"
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -88,6 +89,20 @@ func (r *tenantRepository) FindByIDs(ctx context.Context, ids []string) ([]domai
|
||||
}
|
||||
|
||||
func (r *tenantRepository) AddDomain(ctx context.Context, tenantID string, domainName string, verified bool) error {
|
||||
var existing domain.TenantDomain
|
||||
err := r.db.WithContext(ctx).Unscoped().
|
||||
Where("tenant_id = ? AND domain = ?", tenantID, domainName).
|
||||
First(&existing).Error
|
||||
if err == nil {
|
||||
return r.db.WithContext(ctx).Unscoped().Model(&existing).Updates(map[string]any{
|
||||
"verified": verified,
|
||||
"deleted_at": nil,
|
||||
}).Error
|
||||
}
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
|
||||
td := domain.TenantDomain{
|
||||
TenantID: tenantID,
|
||||
Domain: domainName,
|
||||
|
||||
Reference in New Issue
Block a user