mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 19:38:59 +08:00
Allow user to upload macro files
user is limited to /macro directory for upload/delete admin has full access
This commit is contained in:
parent
7c0afb3f0c
commit
0f13b7b7b0
@ -68,7 +68,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
//version and sources location
|
//version and sources location
|
||||||
#define FW_VERSION "0.7.72"
|
#define FW_VERSION "0.7.73"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP8266"
|
#define REPOSITORY "https://github.com/luc-github/ESP8266"
|
||||||
|
|
||||||
|
|
||||||
|
@ -2108,7 +2108,7 @@ void handle_web_settings()
|
|||||||
STORESTRINGS_CLASS KeysList ;
|
STORESTRINGS_CLASS KeysList ;
|
||||||
STORESTRINGS_CLASS ValuesList ;
|
STORESTRINGS_CLASS ValuesList ;
|
||||||
level_authenticate_type auth_level= web_interface->is_authenticated();
|
level_authenticate_type auth_level= web_interface->is_authenticated();
|
||||||
if (auth_level != LEVEL_ADMIN) {
|
if (auth_level == LEVEL_GUEST) {
|
||||||
web_interface->WebServer.sendContent_P(NOT_AUTH_SET);
|
web_interface->WebServer.sendContent_P(NOT_AUTH_SET);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2429,7 +2429,9 @@ void SPIFFSFileupload()
|
|||||||
{
|
{
|
||||||
HTTPUpload& upload = (web_interface->WebServer).upload();
|
HTTPUpload& upload = (web_interface->WebServer).upload();
|
||||||
if(upload.status == UPLOAD_FILE_START) {
|
if(upload.status == UPLOAD_FILE_START) {
|
||||||
String filename = upload.filename;
|
String filename;
|
||||||
|
if(web_interface->is_authenticated() == LEVEL_ADMIN) filename = upload.filename;
|
||||||
|
else filename = "/macro" + upload.filename;
|
||||||
Serial.println("M117 Start ESP upload");
|
Serial.println("M117 Start ESP upload");
|
||||||
web_interface->fsUploadFile = SPIFFS.open(filename, "w");
|
web_interface->fsUploadFile = SPIFFS.open(filename, "w");
|
||||||
filename = String();
|
filename = String();
|
||||||
@ -2757,12 +2759,14 @@ void handleUpdate()
|
|||||||
|
|
||||||
void handleFileList()
|
void handleFileList()
|
||||||
{
|
{
|
||||||
if (web_interface->is_authenticated() != LEVEL_ADMIN) {
|
level_authenticate_type auth_level = web_interface->is_authenticated();
|
||||||
|
if (auth_level == LEVEL_GUEST) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String path = "/";
|
String path ;
|
||||||
String status="Ok";
|
String status="Ok";
|
||||||
|
if (auth_level == LEVEL_ADMIN) path = "/";
|
||||||
|
else path = "/macro";
|
||||||
if(web_interface->WebServer.hasArg("action")) {
|
if(web_interface->WebServer.hasArg("action")) {
|
||||||
if(web_interface->WebServer.arg("action")=="delete" && web_interface->WebServer.hasArg("filename")) {
|
if(web_interface->WebServer.arg("action")=="delete" && web_interface->WebServer.hasArg("filename")) {
|
||||||
String filename;
|
String filename;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user