|
|
@ -22,15 +22,16 @@ func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityP
|
|
|
|
return nil, errors.Errorf("unsupported idp type %s", string(create.Type))
|
|
|
|
return nil, errors.Errorf("unsupported idp type %s", string(create.Type))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stmt := "INSERT INTO `idp` (`name`, `type`, `identifier_filter`, `config`) VALUES (?, ?, ?, ?)"
|
|
|
|
placeholders := []string{"?", "?", "?", "?"}
|
|
|
|
result, err := d.db.ExecContext(
|
|
|
|
fields := []string{"`name`", "`type`", "`identifier_filter`", "`config`"}
|
|
|
|
ctx,
|
|
|
|
args := []any{create.Name, create.Type, create.IdentifierFilter, string(configBytes)}
|
|
|
|
stmt,
|
|
|
|
|
|
|
|
create.Name,
|
|
|
|
if create.ID != 0 {
|
|
|
|
create.Type,
|
|
|
|
fields, placeholders, args = append(fields, "`id`"), append(placeholders, "?"), append(args, create.ID)
|
|
|
|
create.IdentifierFilter,
|
|
|
|
}
|
|
|
|
string(configBytes),
|
|
|
|
|
|
|
|
)
|
|
|
|
stmt := "INSERT INTO `idp` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholders, ", ") + ")"
|
|
|
|
|
|
|
|
result, err := d.db.ExecContext(ctx, stmt, args...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|