mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
Frontend ip blocking
This commit is contained in:
parent
d25193bb31
commit
3b648ab45e
@ -1,3 +1,4 @@
|
||||
![loli-safe](https://i.imgur.com/YqO1nuc.png)
|
||||
# loli-safe
|
||||
Pomf-like image uploading service, written in NodeJS
|
||||
|
||||
|
@ -6,7 +6,7 @@ let galleryController = {}
|
||||
galleryController.list = function(req, res, next){
|
||||
|
||||
if(!config.privacy.public)
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('Not Authorized!')
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('not-authorized')
|
||||
|
||||
db.table('gallery').select('id', 'name').then((data) => {
|
||||
res.json({ data })
|
||||
@ -16,7 +16,7 @@ galleryController.list = function(req, res, next){
|
||||
galleryController.test = function(req, res, next){
|
||||
|
||||
if(!config.privacy.public)
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('Not Authorized!')
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('not-authorized')
|
||||
|
||||
let testdata = [
|
||||
{name: 'Test 1'},
|
||||
|
@ -25,7 +25,7 @@ uploadsController.upload = function(req, res, next){
|
||||
let gallery = req.headers.gallery
|
||||
|
||||
if(!config.privacy.public)
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('Not Authorized!')
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('not-authorized')
|
||||
|
||||
upload(req, res, function (err) {
|
||||
if (err) {
|
||||
|
@ -28,7 +28,7 @@ div#dropzone {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
border-color: #ff3860;
|
||||
color: #ff3860;
|
||||
display: flex;
|
||||
display: none;
|
||||
width: 100%;
|
||||
border-radius: 3px;
|
||||
box-shadow: none;
|
||||
@ -49,6 +49,7 @@ div#dropzone:hover {
|
||||
border-color: #ff3860;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
img.logo { height: 200px; margin-top: 20px; }
|
||||
.dz-preview .dz-details { display: flex; }
|
||||
.dz-preview .dz-details .dz-size, .dz-preview .dz-details .dz-filename { flex: 1 }
|
||||
|
@ -24,6 +24,7 @@
|
||||
<div class="columns">
|
||||
<div class="column"></div>
|
||||
<div class="column">
|
||||
<a class="button is-danger is-outlined" id='btnGithub' href='https://github.com/kanadeko/loli-safe' target='_blank'>View on Github</a>
|
||||
<div id="dropzone">Click here or drag and drop files</div>
|
||||
</div>
|
||||
<div class="column"></div>
|
||||
@ -57,10 +58,15 @@
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE) {
|
||||
console.log(xhr.responseText)
|
||||
if(xhr.responseText !== 'not-authorized'){
|
||||
document.getElementById('btnGithub').style.display = 'none';
|
||||
document.getElementById('dropzone').style.display = 'flex';
|
||||
}
|
||||
if(xhr.responseText.maxFileSize)
|
||||
maxSize = xhr.responseText.maxFileSize
|
||||
maxSize = xhr.responseText.maxFileSize;
|
||||
if(xhr.responseText.urlPrefix)
|
||||
urlPrefix = xhr.responseText.urlPrefix + '/'
|
||||
urlPrefix = xhr.responseText.urlPrefix + '/';
|
||||
}
|
||||
}
|
||||
xhr.open('GET', '/api/info', true);
|
||||
|
@ -5,7 +5,7 @@ const galleryController = require('../controllers/galleryController')
|
||||
|
||||
routes.get ('/info', (req, res, next) => {
|
||||
if(!config.privacy.public)
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('Not Authorized!')
|
||||
if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('not-authorized')
|
||||
|
||||
return res.json({
|
||||
maxFileSize: config.uploads.maxsize.slice(0, -2),
|
||||
|
Loading…
Reference in New Issue
Block a user