-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsandbox-data.js
More file actions
37 lines (34 loc) · 1.06 KB
/
sandbox-data.js
File metadata and controls
37 lines (34 loc) · 1.06 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
var fs = require('fs');
function data(email, password) {
var Firebase = require('firebase');
var ref = new Firebase('https://firstbuild-sandbox.firebaseio.com');
var credentials = { email: email, password: password };
ref.authWithPassword(credentials, function(err, auth) {
if (err) {
console.error('Failed to login with credentials:', err);
}
else if (auth) {
ref.child('users').child(auth.uid).once('value', function(snapshot) {
console.log(JSON.stringify(snapshot.val(), null, 2));
});
}
else {
console.error('Failed to login with credentials!');
console.error('Make sure you entered your email and password correctly.');
}
});
}
fs.exists('./node_modules/firebase', function(exists) {
if (exists) {
if (process.argv.length == 4) {
data(process.argv[2], process.argv[3]);
}
else {
console.error('usage: node sandbox-data.js <email> <password>');
}
}
else {
console.error('Could not find firebase package!');
console.error('Did you run `npm install firebase`?');
}
});