-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset-admin.mjs
More file actions
24 lines (19 loc) · 807 Bytes
/
set-admin.mjs
File metadata and controls
24 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import admin from 'firebase-admin';
// The 'with { type: "json" }' is important for importing JSON in ES modules.
import serviceAccount from './fine-interface-firebase-adminsdk.json' with { type: 'json' };
// --- Configuration ---
// IMPORTANT: Change this to the email address of the user you want to make an admin.
const userEmail = 'studiominsky@gmail.com';
// ---------------------
try {
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const user = await admin.auth().getUserByEmail(userEmail);
await admin.auth().setCustomUserClaims(user.uid, { admin: true });
console.log(`✅ Successfully set admin claim for ${userEmail}`);
process.exit(0);
} catch (error) {
console.error('❌ Error setting custom claims:', error.message);
process.exit(1);
}