login now checks against db and attaches user data to req.user
This commit is contained in:
@@ -37,16 +37,9 @@ module.exports = class AuthService {
|
||||
try {
|
||||
const user = await UserInstance.findOneByEmail(email);
|
||||
if (!user) throw createError(401, 'Incorrect email or password');
|
||||
// const match = bcrypt.compare(user.password, password, (result, err) => {
|
||||
// if (err) throw err;
|
||||
// return result;
|
||||
// })
|
||||
|
||||
// console.log(match);
|
||||
// if (!match) throw createError(401, 'Incorrect email or password');
|
||||
|
||||
console.log(user.password);
|
||||
|
||||
|
||||
const match = bcrypt.compare(password, user.password).then((result) => console.log(result));
|
||||
if (!match) throw createError(401, 'Incorrect email or password');
|
||||
return user;
|
||||
} catch(e) {
|
||||
throw createError(500, e);
|
||||
|
||||
@@ -15,11 +15,15 @@ module.exports = class CartService {
|
||||
|
||||
async getCart(userid) {
|
||||
const result = await CartInstance.findOneByUserId(userid);
|
||||
if (!result) throw createError(404, "Cart not found");
|
||||
|
||||
console.log(result.id);
|
||||
return result;
|
||||
}
|
||||
|
||||
async addItem(userid, item) {
|
||||
async addItem(userid, itemid) {
|
||||
const cart = await CartInstance.findOneByUserId(userid);
|
||||
const newItem = await CartProductInstance.create(item);
|
||||
const newItem = await CartProductInstance.create(itemid);
|
||||
}
|
||||
|
||||
async removeItem(userid, item) {
|
||||
|
||||
Reference in New Issue
Block a user