-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
148 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
|
||
#Database | ||
USER= | ||
PASSWORD= | ||
DB= | ||
HOST= | ||
|
||
|
||
#Port | ||
PORT= | ||
HOST=localhost | ||
APP_URL=http://localhost:3000 | ||
NODE_ENV=development | ||
|
||
|
||
DEFAULTPROFILEPICLINK= | ||
|
||
#flutterwave | ||
PUBLICK_KEY= | ||
SECRET_KEY= | ||
APP_SECRET_KEY= | ||
|
||
EMAIL= | ||
PASS= | ||
|
||
#aws | ||
AWSSecretKey= | ||
AWSAccessKeyId= | ||
|
||
|
||
CALLBACKURL= | ||
# Call back url for card creation and transaction | ||
CALLBACKURL= | ||
URL= | ||
|
||
|
||
# Card Fee | ||
BASICC= | ||
UNLIMITEDC= | ||
SHAREDC= | ||
TRAVELC= |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const httpStatus = require("http-status"); | ||
// const db = require("../config/db"); | ||
import model from '../models'; | ||
|
||
|
||
const authAdmin = async (req, res, next) => { | ||
try { | ||
const user = req.user; | ||
|
||
const account = await model.Users.findOne({ | ||
where: { | ||
id: user.id | ||
} | ||
}); | ||
//const wallet = await db("wallets").where("user_id", user.id).first(); | ||
|
||
if (account.banned) { | ||
return response.status(403).json({ message: 'You are banned from this site.' }); | ||
} | ||
|
||
if (account.role !== 'admin' && user.role !== 'superadmin') { | ||
return response.status(403).json({ message: 'You are not allowed to access this resource.' }); | ||
} | ||
next(); | ||
} catch (error) { | ||
console.error("authAdmin Middleware Error ==>", error); | ||
return res.status(httpStatus.INTERNAL_SERVER_ERROR).send(error); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
authAdmin, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const httpStatus = require("http-status"); | ||
// const db = require("../config/db"); | ||
import model from '../models'; | ||
|
||
|
||
const authSuperAdmin = async (req, res, next) => { | ||
try { | ||
const user = req.user; | ||
|
||
const account = await model.Users.findOne({ | ||
where: { | ||
id: user.id | ||
} | ||
}); | ||
//const wallet = await db("wallets").where("user_id", user.id).first(); | ||
|
||
if (account.banned) { | ||
return response.status(403).json({ message: 'You are banned from this site.' }); | ||
} | ||
|
||
if (user.role !== 'superadmin') { | ||
return response.status(403).json({ message: 'You are not allowed to access this resource.' }); | ||
} | ||
next(); | ||
} catch (error) { | ||
console.error("authSuperAdmin Middleware Error ==>", error); | ||
return res.status(httpStatus.INTERNAL_SERVER_ERROR).send(error); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
authSuperAdmin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module.exports.auth = require('./auth'); | ||
module.exports.authAdmin = require('./auth-admin'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
const express = require("express"); | ||
const userController = require("../controllers/user.controller"); | ||
const { userValidation } = require("../validations"); | ||
const { auth } = require("../middlewares/auth"); | ||
const { auth, authAdmin } = require("../middlewares"); | ||
|
||
const router = express.Router(); | ||
|
||
router.post("/register", userValidation.register, userController.register); | ||
router.post("/login", userValidation.login, userController.login); | ||
router.get("/auth/profile", [auth], userController.getProfile); | ||
router.get("/getallusers", userController.getAllusers); | ||
router.get("/getallusers", [auth, authAdmin], userController.getAllusers); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters