mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-06 10:11:28 +03:00
added ability to set pin for settings. pin is md5'd by the backend
This commit is contained in:
@@ -9,6 +9,7 @@ var express = require("express");
|
||||
var bodyParser = require("body-parser");
|
||||
var archiver = require('archiver');
|
||||
const low = require('lowdb')
|
||||
var md5 = require('md5');
|
||||
var URL = require('url').URL;
|
||||
const shortid = require('shortid')
|
||||
const url_api = require('url');
|
||||
@@ -29,7 +30,8 @@ db.defaults(
|
||||
video: []
|
||||
},
|
||||
configWriteFlag: false,
|
||||
subscriptions: []
|
||||
subscriptions: [],
|
||||
pin_md5: ''
|
||||
}).write();
|
||||
|
||||
// config values
|
||||
@@ -1176,6 +1178,47 @@ app.post('/api/downloadArchive', async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.post('/api/isPinSet', async (req, res) => {
|
||||
let stored_pin = db.get('pin_md5').value();
|
||||
let is_set = false;
|
||||
if (!stored_pin || stored_pin.length === 0) {
|
||||
} else {
|
||||
is_set = true;
|
||||
}
|
||||
|
||||
res.send({
|
||||
is_set: is_set
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/api/setPin', async (req, res) => {
|
||||
let unhashed_pin = req.body.pin;
|
||||
let hashed_pin = md5(unhashed_pin);
|
||||
|
||||
db.set('pin_md5', hashed_pin).write();
|
||||
|
||||
res.send({
|
||||
success: true
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/api/checkPin', async (req, res) => {
|
||||
let input_pin = req.body.input_pin;
|
||||
let input_pin_md5 = md5(input_pin);
|
||||
|
||||
let stored_pin = db.get('pin_md5').value();
|
||||
|
||||
let successful = false;
|
||||
|
||||
if (input_pin_md5 === stored_pin) {
|
||||
successful = true;
|
||||
}
|
||||
|
||||
res.send({
|
||||
success: successful
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/video/:id', function(req , res){
|
||||
var head;
|
||||
let optionalParams = url_api.parse(req.url,true).query;
|
||||
|
||||
Reference in New Issue
Block a user