Fix issue with login not adding details to user database

This commit is contained in:
2017-10-13 19:47:47 +01:00
parent 681dd80d3b
commit 1341258c32
3 changed files with 55 additions and 38 deletions

View File

@@ -8,24 +8,32 @@ const route = function (db) {
});
router.get('/:uid', function(req, res, next) {
const uid = req.params.uid;
const userRef = db.ref(`/users/${uid}`);
userRef.set({
approved: true,
});
admin.auth().createCustomToken(uid, {
approved: true,
}).then(function(customToken) {
return res.json({
success: true,
token: customToken,
admin.auth().getUser(uid)
.then(function() {
const userRef = db.ref(`/users/${uid}`);
userRef.set({
approved: true,
});
admin.auth().createCustomToken(uid, {
approved: true,
}).then(function(customToken) {
return res.json({
success: true,
token: customToken,
});
}).catch(function(err) {
console.error('Error creating custom token', err);
return res.status(500).json({
success: false,
error: err,
});
});
}).catch(function(err) {
return res.json({
success: false,
error: err,
});
});
}).catch(function(err) {
console.error('Error creating custom token', err);
return res.status(500).json({
success: false,
error: err,
});
});
});
return router;
}