-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchange-email.js
More file actions
40 lines (34 loc) · 1.08 KB
/
change-email.js
File metadata and controls
40 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fb = require("firebase-admin");
const serviceAccount = require("../private/service-account.json");
// This script will change an account email.
const from = 'abianch@sunburymanor.surrey.sch.uk'
const to = 'abianchi@sunburymanor.surrey.sch.uk'
fb.initializeApp({
credential: fb.credential.cert(serviceAccount),
databaseURL: "https://parallel-beta-31dc4.firebaseio.com",
});
const run = () =>
fb
.auth()
.getUserByEmail(from)
.then(async (user) => {
await fb.auth().updateUser(user.uid, {
email: to,
});
console.log(`\nMigrated "${user.email}" email to ${to}`);
console.log(`\nIf this student is Parallel Academy, please send Drew "${user.uid}" and "${to}" to update the Parallel Academy account.`)
})
.catch((err) => {
err.message = `${err.message} - ${from}`;
throw err;
});
run()
.then(() => {
console.error("\n\n\nSuccess migrating account");
process.exit(0);
})
.catch((err) => {
console.error("\n\n\nError migrating account!");
console.error(err.message + "\n");
process.exit(1);
});