public vs general, roles

This commit is contained in:
Arjun Patel
2019-02-27 20:05:33 -08:00
parent 833c87d1ec
commit d14e111f53
13 changed files with 772 additions and 23 deletions
@@ -3,7 +3,12 @@ const db = require('../../config/db.config.js'),
const { Grant, Cause, Region, Organization } = db;
// PUT to change specific org's verify column to true
exports.verifyOrg = (req, res, next) => {
// Verify charity
exports.verifyOrg = async (req, res, next) => {
const charity_id = req.params.charity_id;
await db.sequelize.query("UPDATE organizations SET verified = 1 WHERE id = :charity_id",
{ replacements: {charity_id} });
return res.status(200).json({ message: "Successfully verified charity" });
};
+2 -2
View File
@@ -5,10 +5,10 @@ const express = require('express'),
const controllers = require('../controllers/admin');
// PUT Manual verification of a charity
// Manual verification of a charity
// TODO: Add checkAuth(roles.ADMIN) back into middleware
router.put(
'/org/:charity_id',
checkAuth(roles.ADMIN),
controllers.organization.verifyOrg
);
+5 -6
View File
@@ -5,19 +5,18 @@ const express = require('express'),
const controllers = require('../controllers/donor');
// POST Signup route
// POST donor signup
router.post('/', controllers.donor.create);
// GET Retrieve all Donors
// GET all Donors
router.get('/', checkAuth(roles.ADMIN), controllers.donor.findAll);
// GET Retrieve grants with causes and regions and charities details by donor_id
// GET grants with causes, regions, charities by donor_id
router.get('/grants/', checkAuth(roles.DONOR), controllers.grant.findByDonorId);
/** POST Create grants with following body:
* - list of id's of selected causes and regions
* - FINAL list of id's of selected organizations
* - monthly true or false
* - List of id's of selected causes, regions, charities
* - Monthly: true or false
* - donor_id
* */
router.post(
+3 -3
View File
@@ -5,13 +5,13 @@ const express = require('express'),
const controllers = require('../controllers/organization');
// POST Signup route
// Charity signup route
router.post('/', controllers.organization.create);
// POST add cause
// Add cause
router.post('/cause', checkAuth(roles.ORGANIZATION), controllers.cause.create);
// POST add region
// Add region
router.post(
'/region',
checkAuth(roles.ORGANIZATION),
@@ -1,7 +1,7 @@
const express = require('express'),
router = express.Router();
const controllers = require('../controllers/general');
const controllers = require('../controllers/public');
// Retrieve all causes
router.get('/causes', controllers.cause.findAll);
@@ -12,11 +12,11 @@ router.get('/regions', controllers.region.findAll);
// Retrieve all organizations
router.get('/organizations', controllers.organization.findAll);
// Retrieve based on inputted search
// limitted numer returned; empty input still returns orgs
// Retrieve charities based on inputted search
// TODO: fix sql injection attack
router.get('/organizations/:search', controllers.organization.searchOrgs);
// Add email to database from the landing page
// Add user email to database from the landing page
router.post('/users/landing', controllers.user.addEmail);
module.exports = router;