-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return an error page for the blocked users. Changed the returned stat…
…us code from 429 to 403. This is to better reflect the functionality of a blocklist rather than rate limiting which 429 implies. Signed-off-by: Michael Cinkus <[email protected]>
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
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
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,57 @@ | ||
const utils = require(__dirname + '/../lib/utils') | ||
|
||
const blocklist = (req) => { | ||
const body = ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>403 Forbidden!</title> | ||
<style> | ||
header { | ||
width: 100%; | ||
height: 100px; | ||
background-color: #CB4C3D; | ||
color: white; | ||
text-align: center; | ||
display: -webkit-box; | ||
display: -ms-flexbox; | ||
display: flex; | ||
-webkit-box-pack: center; | ||
-ms-flex-pack: center; | ||
justify-content: center; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
align-items: center; | ||
} | ||
code { | ||
font-weight: bold; | ||
font-style: italic; | ||
background-color: #EFF0F1; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<main> | ||
<header> | ||
<h1>ERROR 403 - Forbidden!</h1> | ||
</header> | ||
<section> | ||
<h2>The following error occurrred:</h2> | ||
<p>Requests for user <code>${req.params.user}</code> are blocked.</p> | ||
<hr> | ||
<p>If you believe this is an error or would like to dispute this block then contact: <a href="mailto:[email protected]">[email protected]</a></p> | ||
</section> | ||
</main> | ||
</body> | ||
</html> | ||
` | ||
|
||
return { | ||
body, | ||
statusCode: 403 | ||
} | ||
} | ||
|
||
module.exports = blocklist |