Initial miaojingAI project with image resolution guard
This commit is contained in:
49
verify_admin_import.js
Normal file
49
verify_admin_import.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const base = 'http://127.0.0.1:5000';
|
||||
|
||||
(async () => {
|
||||
const profileRes = await fetch(`${base}/api/profile?email=admin@example.com`);
|
||||
const profileData = await profileRes.json();
|
||||
const adminId = profileData.profile && profileData.profile.id;
|
||||
if (!adminId) throw new Error('admin profile not found');
|
||||
const token = `token-admin-${adminId}-${Date.now()}`;
|
||||
|
||||
const noAuth = await fetch(`${base}/api/admin/data-import`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: '{}',
|
||||
});
|
||||
const noAuthText = await noAuth.text();
|
||||
|
||||
const payload = {
|
||||
_meta: {
|
||||
version: '1.0',
|
||||
platform: 'miaojing',
|
||||
exported_at: new Date().toISOString(),
|
||||
tables: [],
|
||||
counts: {},
|
||||
},
|
||||
data: {
|
||||
auth_users: [],
|
||||
profiles: [],
|
||||
works: [],
|
||||
user_api_keys: [],
|
||||
},
|
||||
};
|
||||
const authed = await fetch(`${base}/api/admin/data-import`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const authedText = await authed.text();
|
||||
|
||||
console.log(JSON.stringify({
|
||||
noAuth: { status: noAuth.status, body: noAuthText },
|
||||
authed: { status: authed.status, body: authedText },
|
||||
}, null, 2));
|
||||
})().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user