-
Notifications
You must be signed in to change notification settings - Fork 2
/
create.js
29 lines (25 loc) · 759 Bytes
/
create.js
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
'use strict';
const admin = require('./firebase-admin');
module.exports.create = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
const request = JSON.parse(event.body);
admin.auth().createUser({
uid: request.uid,
email: request.email,
password: request.password
}).then(function(user) {
console.log('Successfully created new user:', user);
const response = {
statusCode: 200,
body: JSON.stringify(user),
};
callback(null, response);
}).catch(function(error) {
console.log('Error creating new user:', error);
callback(null, {
statusCode: 501,
headers: { 'Content-Type': 'text/plain' },
body: 'Couldn\'t create the user',
});
});
};