Save password last to avoid auth check preventing saving other settings
Because saveSetting() checks each time to see that the user has authenticated, if the password is changed first then very next setting will cause a auth prompt (as the password changed) and if cancelled then the other setting won't save. Putting it last will allow us to save all the other setting and then change the password, then the next attempt to execute a action or access a page that required auth will prompt the user the the password.
This commit is contained in:
+22
-15
@@ -23,26 +23,11 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
}
|
||||
|
||||
if(isset($_GET['submit'])) {
|
||||
if(isset($_GET["caddy_pwd"])) {
|
||||
$caddy_pwd = $_GET["caddy_pwd"];
|
||||
saveSetting('CADDY_PWD', "\"$caddy_pwd\"");
|
||||
//Make sure the caddy file is set directly
|
||||
update_caddyfile();
|
||||
}
|
||||
|
||||
if(isset($_GET["ice_pwd"])) {
|
||||
$ice_pwd = $_GET["ice_pwd"];
|
||||
saveSetting('ICE_PWD', $ice_pwd);
|
||||
}
|
||||
|
||||
if(isset($_GET["birdnetpi_url"])) {
|
||||
$birdnetpi_url = $_GET["birdnetpi_url"];
|
||||
// remove trailing slash to prevent conf from becoming broken
|
||||
$birdnetpi_url = rtrim($birdnetpi_url, '/');
|
||||
saveSetting('BIRDNETPI_URL', $birdnetpi_url);
|
||||
update_caddyfile();
|
||||
}
|
||||
|
||||
if(isset($_GET["rtsp_stream"])) {
|
||||
$rtsp_stream = str_replace("\r\n", ",", $_GET["rtsp_stream"]);
|
||||
saveSetting('RTSP_STREAM', "\"$rtsp_stream\"", ['restart birdnet_recording', 'restart livestream']);
|
||||
@@ -165,6 +150,28 @@ if(isset($_GET['submit'])) {
|
||||
|
||||
saveSetting('LogLevel_LiveAudioStreamService', "\"$livestream_audio_service_log_level\"",['restart livestream','restart icecast2']);
|
||||
}
|
||||
|
||||
if(isset($_GET["birdnetpi_url"])) {
|
||||
$birdnetpi_url = $_GET["birdnetpi_url"];
|
||||
// remove trailing slash to prevent conf from becoming broken
|
||||
$birdnetpi_url = rtrim($birdnetpi_url, '/');
|
||||
saveSetting('BIRDNETPI_URL', $birdnetpi_url);
|
||||
update_caddyfile();
|
||||
}
|
||||
|
||||
if(isset($_GET["caddy_pwd"])) {
|
||||
$caddy_pwd_value = "";
|
||||
$caddy_pwd = $_GET["caddy_pwd"];
|
||||
//If the BirdNET-Pi Password is empty, return a empty string instead of a string that was surrounded by double quotes
|
||||
//else return the supplied password
|
||||
//so in the ini file ['CADDY_PWD']= , instead of ['CADDY_PWD']="" (which still prompts for auth but password is required)
|
||||
//this returns the password setting to it's default state when no password is set
|
||||
$caddy_pwd_value = !empty($caddy_pwd) ? "\"$caddy_pwd\"" : "";
|
||||
|
||||
saveSetting('CADDY_PWD', "$caddy_pwd_value");
|
||||
//Make sure the caddy file is set directly
|
||||
update_caddyfile();
|
||||
}
|
||||
}
|
||||
|
||||
$count = getLabelsCount();
|
||||
|
||||
Reference in New Issue
Block a user