Fix: Add use_for_verification field to CF account creation/update
This commit is contained in:
parent
2e863a4098
commit
8f64b61d1d
|
|
@ -54,7 +54,8 @@ def create_cf_account(current_admin):
|
||||||
api_token=data['api_token'], # TODO: Encrypt this
|
api_token=data['api_token'], # TODO: Encrypt this
|
||||||
max_domains=data.get('max_domains', 100),
|
max_domains=data.get('max_domains', 100),
|
||||||
notes=data.get('notes'),
|
notes=data.get('notes'),
|
||||||
is_active=data.get('is_active', True)
|
is_active=data.get('is_active', True),
|
||||||
|
use_for_verification=data.get('use_for_verification', True)
|
||||||
)
|
)
|
||||||
|
|
||||||
db.session.add(account)
|
db.session.add(account)
|
||||||
|
|
@ -105,6 +106,8 @@ def update_cf_account(current_admin, account_id):
|
||||||
account.notes = data['notes']
|
account.notes = data['notes']
|
||||||
if 'is_active' in data:
|
if 'is_active' in data:
|
||||||
account.is_active = data['is_active']
|
account.is_active = data['is_active']
|
||||||
|
if 'use_for_verification' in data:
|
||||||
|
account.use_for_verification = data['use_for_verification']
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
-- Migration: Add use_for_verification field to cloudflare_account table
|
||||||
|
-- Date: 2026-01-12
|
||||||
|
|
||||||
|
-- Add use_for_verification column
|
||||||
|
ALTER TABLE cloudflare_account
|
||||||
|
ADD COLUMN IF NOT EXISTS use_for_verification BOOLEAN DEFAULT TRUE;
|
||||||
|
|
||||||
|
-- Update existing records to TRUE (default behavior)
|
||||||
|
UPDATE cloudflare_account
|
||||||
|
SET use_for_verification = TRUE
|
||||||
|
WHERE use_for_verification IS NULL;
|
||||||
|
|
||||||
|
-- Add comment
|
||||||
|
COMMENT ON COLUMN cloudflare_account.use_for_verification IS 'Whether this account can be used for customer domain verification';
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@ const CFAccounts = () => {
|
||||||
max_domains: 100,
|
max_domains: 100,
|
||||||
notes: '',
|
notes: '',
|
||||||
is_active: true,
|
is_active: true,
|
||||||
|
use_for_verification: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -67,6 +68,7 @@ const CFAccounts = () => {
|
||||||
max_domains: account.max_domains,
|
max_domains: account.max_domains,
|
||||||
notes: account.notes || '',
|
notes: account.notes || '',
|
||||||
is_active: account.is_active,
|
is_active: account.is_active,
|
||||||
|
use_for_verification: account.use_for_verification !== undefined ? account.use_for_verification : true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
@ -83,6 +85,7 @@ const CFAccounts = () => {
|
||||||
max_domains: 100,
|
max_domains: 100,
|
||||||
notes: '',
|
notes: '',
|
||||||
is_active: true,
|
is_active: true,
|
||||||
|
use_for_verification: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -221,6 +224,21 @@ const CFAccounts = () => {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={formData.use_for_verification}
|
||||||
|
onChange={(e) => setFormData({ ...formData, use_for_verification: e.target.checked })}
|
||||||
|
className="w-4 h-4"
|
||||||
|
/>
|
||||||
|
<span className="text-sm">Use for Domain Verification</span>
|
||||||
|
</label>
|
||||||
|
<p className="text-xs text-gray-500 mt-1 ml-6">
|
||||||
|
Allow this account to be used for customer domain verification
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-3 pt-4">
|
<div className="flex gap-3 pt-4">
|
||||||
<button type="submit" className="btn-primary flex-1">
|
<button type="submit" className="btn-primary flex-1">
|
||||||
{editingAccount ? 'Update Account' : 'Create Account'}
|
{editingAccount ? 'Update Account' : 'Create Account'}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue