2022-03-22 07:03:17 -06:00
|
|
|
import authenticationController from '../controllers/authentication';
|
|
|
|
|
2022-03-22 09:14:08 -06:00
|
|
|
export const getAccount = async (req, res, next) => {
|
|
|
|
req.account = await authenticationController.getAuthenticatedAccount(req);
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
|
2022-03-23 18:00:25 -06:00
|
|
|
export const requireAuthenticated = async (req, res, next) => {
|
2022-03-22 07:03:17 -06:00
|
|
|
const account = await authenticationController.getAuthenticatedAccount(req);
|
2022-05-01 16:17:00 -06:00
|
|
|
console.log(account);
|
2022-03-22 07:03:17 -06:00
|
|
|
if (!account) {
|
|
|
|
res.status(401).json({
|
|
|
|
success: false,
|
|
|
|
code: 'NOT_AUTHENTICATED',
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-23 18:00:43 -06:00
|
|
|
req.account = account;
|
2022-03-22 07:03:17 -06:00
|
|
|
next();
|
|
|
|
};
|
|
|
|
|
|
|
|
export default null;
|