]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Setup: actually delete data/database.php as well (after confirmation)
authorBram Matthys <redacted>
Sun, 23 Apr 2023 16:00:39 +0000 (18:00 +0200)
committerBram Matthys <redacted>
Sun, 23 Apr 2023 16:01:29 +0000 (18:01 +0200)
Similar to previous commit, but for file_auth instead of sql_auth.

plugins/file_auth/file_auth.php
settings/install.php

index ece2bd2061ef2d7bbe2702f59e8a8b079922ab9f..bb7dc4211fe5df1cd4427516068756221446ab15 100644 (file)
@@ -144,11 +144,9 @@ class file_auth
                return true;
        }
 
-       public static function read_db()
+       public static function minimal_db()
        {
                GLOBAL $db;
-               $db_filename = UPATH.'/data/database.php';
-               @include($db_filename);
                /* Add at least the general arrays: */
                if (!isset($db["users"]))
                        $db["users"] = [];
@@ -156,6 +154,22 @@ class file_auth
                        $db["settings"] = [];
                /* Initialize more if we ever add more... */
        }
+       public static function read_db()
+       {
+               GLOBAL $db;
+               $db_filename = UPATH.'/data/database.php';
+               @include($db_filename);
+               file_auth::minimal_db();
+       }
+
+       /* Delete the database -- only called during setup AFTER confirmation! */
+       public static function delete_db()
+       {
+               GLOBAL $db;
+               $db = [];
+               file_auth::minimal_db();
+               file_auth::write_db(true);
+       }
 
        public static function write_db($force = false)
        {
index b96cc9a48e14db61f52490d9c2550bf6f49195ac..99c79b7b29c0ac6af1f6975aabdb14f4eb7abc3e 100644 (file)
@@ -139,6 +139,9 @@ $writable = (is_writable("../config/")) ? true: false;
                        sql_auth::delete_tables();
                        if (!sql_auth::create_tables())
                                Message::Fail("Could not create SQL tables");
+               } else if ($auth_method == "file_auth")
+               {
+                       file_auth::delete_db();
                }
 
                $user = [