preparing to checkout

This commit is contained in:
Mikayla Dobson
2022-11-30 18:33:40 -06:00
parent 9d0c8a8782
commit ba4b6e08c9
6 changed files with 39 additions and 17 deletions

View File

@@ -22,7 +22,7 @@ export default class AuthService {
if (user) throw createError('409', 'Email already in use');
// hash password and create new user record
return bcrypt.genSalt(10, (err, salt) => {
bcrypt.genSalt(10, (err, salt) => {
if (err) throw err;
bcrypt.hash(password!, salt, async (err, hash) => {
if (err) throw err;
@@ -46,6 +46,8 @@ export default class AuthService {
return result;
})
})
return true;
} catch (e: any) {
throw new Error(e);
}

View File

@@ -8,6 +8,8 @@ import { appRoot } from "../appRoot";
dotenv.config();
(async function() {
console.clear();
const setRole = `
SET ROLE postgres;
DROP SCHEMA IF EXISTS recipin CASCADE;

View File

@@ -15,8 +15,10 @@ export const authRoute = (app: Express, passport: PassportStatic) => {
app.use('/auth', router);
router.get('/', restrictAccess, (req, res, next) => {
if (!req.user) return;
// @ts-ignore: does not recognize structure of req.user
const user = req.user?.user;
const { user } = req.user;
const userData = {
id: user.id,
firstname: user.firstname,