Skip to content

Commit

Permalink
Error Page for Different Conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Silfer committed Apr 2, 2017
1 parent 5188fec commit c88c4e3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 14 deletions.
41 changes: 39 additions & 2 deletions source/controller/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if (!usehttps) {
* @param res
* @param next
*/

var errorMessage = "";

var get = function (req, res, next) {

if (req.body.auth.success) {
Expand All @@ -35,8 +38,24 @@ if (!usehttps) {
}
});
} else {
//res.send('Auth unsuccessful');
res.redirect('/error');
res.send('Auth unsuccessful');
//res.render('\error', {title: '404: File Not Found'});
//res.redirect('/error');

//errorMessage = "Failure to Authenticate";
/*var drinks = [
{ name: 'Bloody Mary', drunkness: 3 },
{ name: 'Martini', drunkness: 5 },
{ name: 'Scotch', drunkness: 10 }
];
var tagline = "Any code of your own that you haven't looked at for six or more months might as well have been written by someone else.";*/

/*res.render('error.ejs', {
errorMessage: errorMessage
//drinks: drinks,
//tagline: tagline
});*/

}

}
Expand All @@ -52,6 +71,12 @@ var forceSyncIVLE = function (req, res, next) {
});
} else {
res.send("Permission denied");

/*errorMessage = "Permission denied.";
res.render('error.ejs', {
errorMessage: errorMessage
});*/
}
}

Expand All @@ -75,6 +100,12 @@ var getTutorials = function (req, res, next) {

} else {
res.send("Permission denied");

/*errorMessage = "Permission denied.";
res.render('error.ejs', {
errorMessage: errorMessage
});*/
}
}

Expand All @@ -86,6 +117,12 @@ var syncUser = function (req, res, next) {
});
} else {
res.send("Permission denied");

/*errorMessage = "Permission denied.";
res.render('error.ejs', {
errorMessage: errorMessage
});*/
}
}

Expand Down
25 changes: 18 additions & 7 deletions source/controller/lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var app = require('../../app');
* @param res
* @param next
*/

var get = function (req, res, next)
{

Expand All @@ -32,8 +33,13 @@ var get = function (req, res, next)

} else {
//console.log('fail');
//res.send('Auth unsuccessful.')
res.redirect('/error');
res.send('Auth unsuccessful 2.');

/*var errorMessage = "Auth unsuccessful";
res.render('error.ejs', {
errorMessage: errorMessage
});*/
}
};

Expand Down Expand Up @@ -74,19 +80,23 @@ var enterLobby = function (req, res, next) {
});
} else {
//res.json({ success: false, message: 'The tutor of this tutorial class has not registered with the system.'});
res.redirect('/error');
//res.redirect('/error');

var errorMessage = "Auth unsuccessful 3";

res.render('error.ejs', {
errorMessage: errorMessage
});
}
});

} else {
//res.json({ success: false, message: 'You are not a member of this tutorial.'});
res.redirect('/error');
res.json({ success: false, message: 'You are not a member of this tutorial.'});
}
});

} else {
//res.json({success: false, message: 'Please access lobby from dashboard!'});
res.redirect('/error');
res.json({success: false, message: 'Please access lobby from dashboard!'});
}
}

Expand All @@ -95,6 +105,7 @@ var enterLobby = function (req, res, next) {
* Check if user is a tutor of class.
* @param uid
* @param tid
* @return boolean
*/
var userIsTutorOfClass = function (uid, tid) {
Expand Down
12 changes: 7 additions & 5 deletions source/view/error.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<title>Error Page</title>
<title></title>

<script type='text/javascript' src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.2.0.min.js'></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.0/js.cookie.min.js"></script>
Expand All @@ -19,15 +19,15 @@
<li><a class="active" href="/">Error! Click here to return!</a></li>
</ul>

<h2>Error Message</h2>
<p><%=errorMessage%></p>

</body>
</html>

<script>
</script>

<style>
body {
background-color: #E0FFFF;
background-color: #FFFFFF;
}
ul {
Expand All @@ -54,4 +54,6 @@
li a:hover {
background-color: #B7B7B6;
}
</style>

0 comments on commit c88c4e3

Please sign in to comment.