mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-01 17:22:42 +00:00
set up error page
This commit is contained in:
@@ -2,6 +2,9 @@ const dedent = require('dedent-tabs').default;
|
|||||||
|
|
||||||
const loginUrl = 'https://www.naturalcrit.com/login';
|
const loginUrl = 'https://www.naturalcrit.com/login';
|
||||||
|
|
||||||
|
//001-050 : Brew errors
|
||||||
|
//050-100 : Other pages errors
|
||||||
|
|
||||||
const errorIndex = (props)=>{
|
const errorIndex = (props)=>{
|
||||||
return {
|
return {
|
||||||
// Default catch all
|
// Default catch all
|
||||||
@@ -149,6 +152,14 @@ const errorIndex = (props)=>{
|
|||||||
|
|
||||||
**Brew ID:** ${props.brew.brewId}`,
|
**Brew ID:** ${props.brew.brewId}`,
|
||||||
|
|
||||||
|
//account page when account is not defined
|
||||||
|
'50' : dedent`
|
||||||
|
## You are not signed in
|
||||||
|
|
||||||
|
You are trying to access the account page. This page can only be accessed if you are signed in an account.
|
||||||
|
|
||||||
|
Please login or signup at our [login page](https://www.naturalcrit.com/login?redirect=https://homebrewery.naturalcrit.com/account) `,
|
||||||
|
|
||||||
// Brew locked by Administrators error
|
// Brew locked by Administrators error
|
||||||
'100' : dedent`
|
'100' : dedent`
|
||||||
## This brew has been locked.
|
## This brew has been locked.
|
||||||
|
|||||||
@@ -358,10 +358,18 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
|
|||||||
|
|
||||||
//Account Page
|
//Account Page
|
||||||
app.get('/account', asyncHandler(async (req, res, next)=>{
|
app.get('/account', asyncHandler(async (req, res, next)=>{
|
||||||
if(!req.account) return res.redirect('/');
|
|
||||||
const data = {};
|
const data = {};
|
||||||
data.title = 'Account Information Page';
|
data.title = 'Account Information Page';
|
||||||
|
|
||||||
|
if(!req.account) {
|
||||||
|
res.set('WWW-Authenticate', 'Bearer realm="Authorization Required"');
|
||||||
|
const error = new Error('No valid account');
|
||||||
|
error.status = 401;
|
||||||
|
error.HBErrorCode = '50';
|
||||||
|
error.page = data.title;
|
||||||
|
return next(error);
|
||||||
|
};
|
||||||
|
|
||||||
let auth;
|
let auth;
|
||||||
let googleCount = [];
|
let googleCount = [];
|
||||||
if(req.account) {
|
if(req.account) {
|
||||||
|
|||||||
Reference in New Issue
Block a user