Fixes and upgrades (logging in / CORS headers expose / registering)

This commit is contained in:
2020-08-09 17:50:03 +02:00
parent 91cba76bff
commit 65939f314f
5 changed files with 23 additions and 42 deletions

View File

@@ -22,7 +22,7 @@ export function validateRestaurant(id, callback) {
} else callback(false);
}
export function fetchUserHash(email, callback) {
export function fetchUser(email, callback) {
User.findOne({ email: email }, (err, res) => {
if (err || res === null) {
callback(false);
@@ -34,7 +34,13 @@ export function fetchUserHash(email, callback) {
export function generateAuthToken(user) {
const token = jwt.sign(
{ email: user.email, subcsriptionActive: user.subscriptionActive },
{
email: user.email,
firstname: user.firstname,
lastname: user.lastname,
id: user._id,
restaurants: user.restaurants,
},
jwtSecret,
{ expiresIn: "1h" }
);
@@ -224,16 +230,6 @@ export function composeNewContact(request) {
name: "UserID",
value: request._id,
},
{
type: "CUSTOM",
name: "Subscription Started",
value: toShortDate(dateNow),
},
{
type: "CUSTOM",
name: "Subscription Due",
value: request.subscriptionDue,
},
],
};