jblanked 1 год назад
Родитель
Сommit
f52c027343
2 измененных файлов с 58 добавлено и 27 удалено
  1. 10 0
      flip_social_draw.h
  2. 48 27
      flip_social_storage.h

+ 10 - 0
flip_social_draw.h

@@ -472,6 +472,16 @@ static void flip_social_callback_draw_login(Canvas *canvas, void *model)
 
 
                 app_instance->is_logged_in = "true";
                 app_instance->is_logged_in = "true";
 
 
+                // set the logged_in_username and change_password_logged_in
+                if (app_instance->login_username_logged_out)
+                {
+                    strcpy(app_instance->login_username_logged_in, app_instance->login_username_logged_out);
+                }
+                if (app_instance->login_password_logged_out)
+                {
+                    app_instance->change_password_logged_in = app_instance->login_password_logged_out;
+                }
+
                 save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
                 save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
 
 
                 // send user to the logged in submenu
                 // send user to the logged in submenu

+ 48 - 27
flip_social_storage.h

@@ -272,7 +272,10 @@ static bool load_settings(
         furi_record_close(RECORD_STORAGE);
         furi_record_close(RECORD_STORAGE);
         return false;
         return false;
     }
     }
-    ssid[ssid_length - 1] = '\0'; // Ensure null-termination
+    else
+    {
+        ssid[ssid_length - 1] = '\0'; // Ensure null-termination
+    }
 
 
     // Load the password
     // Load the password
     size_t password_length;
     size_t password_length;
@@ -285,7 +288,10 @@ static bool load_settings(
         furi_record_close(RECORD_STORAGE);
         furi_record_close(RECORD_STORAGE);
         return false;
         return false;
     }
     }
-    password[password_length - 1] = '\0'; // Ensure null-termination
+    else
+    {
+        password[password_length - 1] = '\0'; // Ensure null-termination
+    }
 
 
     // Load the login_username_logged_out
     // Load the login_username_logged_out
     size_t username_out_length;
     size_t username_out_length;
@@ -293,12 +299,15 @@ static bool load_settings(
         storage_file_read(file, login_username_logged_out, username_out_length) != username_out_length)
         storage_file_read(file, login_username_logged_out, username_out_length) != username_out_length)
     {
     {
         FURI_LOG_E(TAG, "Failed to read login_username_logged_out");
         FURI_LOG_E(TAG, "Failed to read login_username_logged_out");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
+        // storage_file_close(file);
+        // storage_file_free(file);
+        // furi_record_close(RECORD_STORAGE);
+        // return false;
+    }
+    else
+    {
+        login_username_logged_out[username_out_length - 1] = '\0'; // Ensure null-termination
     }
     }
-    login_username_logged_out[username_out_length - 1] = '\0'; // Ensure null-termination
 
 
     // Load the login_username_logged_in
     // Load the login_username_logged_in
     size_t username_in_length;
     size_t username_in_length;
@@ -306,12 +315,15 @@ static bool load_settings(
         storage_file_read(file, login_username_logged_in, username_in_length) != username_in_length)
         storage_file_read(file, login_username_logged_in, username_in_length) != username_in_length)
     {
     {
         FURI_LOG_E(TAG, "Failed to read login_username_logged_in");
         FURI_LOG_E(TAG, "Failed to read login_username_logged_in");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
+        // storage_file_close(file);
+        // storage_file_free(file);
+        // furi_record_close(RECORD_STORAGE);
+        // return false;
+    }
+    else
+    {
+        login_username_logged_in[username_in_length - 1] = '\0'; // Ensure null-termination
     }
     }
-    login_username_logged_in[username_in_length - 1] = '\0'; // Ensure null-termination
 
 
     // Load the login_password_logged_out
     // Load the login_password_logged_out
     size_t password_out_length;
     size_t password_out_length;
@@ -319,12 +331,15 @@ static bool load_settings(
         storage_file_read(file, login_password_logged_out, password_out_length) != password_out_length)
         storage_file_read(file, login_password_logged_out, password_out_length) != password_out_length)
     {
     {
         FURI_LOG_E(TAG, "Failed to read login_password_logged_out");
         FURI_LOG_E(TAG, "Failed to read login_password_logged_out");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
+        // storage_file_close(file);
+        // storage_file_free(file);
+        // furi_record_close(RECORD_STORAGE);
+        // return false;
+    }
+    else
+    {
+        login_password_logged_out[password_out_length - 1] = '\0'; // Ensure null-termination
     }
     }
-    login_password_logged_out[password_out_length - 1] = '\0'; // Ensure null-termination
 
 
     // Load the change_password_logged_in
     // Load the change_password_logged_in
     size_t change_password_length;
     size_t change_password_length;
@@ -332,12 +347,15 @@ static bool load_settings(
         storage_file_read(file, change_password_logged_in, change_password_length) != change_password_length)
         storage_file_read(file, change_password_logged_in, change_password_length) != change_password_length)
     {
     {
         FURI_LOG_E(TAG, "Failed to read change_password_logged_in");
         FURI_LOG_E(TAG, "Failed to read change_password_logged_in");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
+        // storage_file_close(file);
+        // storage_file_free(file);
+        // furi_record_close(RECORD_STORAGE);
+        //  return false;
+    }
+    else
+    {
+        change_password_logged_in[change_password_length - 1] = '\0'; // Ensure null-termination
     }
     }
-    change_password_logged_in[change_password_length - 1] = '\0'; // Ensure null-termination
 
 
     // Load the is_logged_in
     // Load the is_logged_in
     size_t is_logged_in_length;
     size_t is_logged_in_length;
@@ -345,12 +363,15 @@ static bool load_settings(
         storage_file_read(file, is_logged_in, is_logged_in_length) != is_logged_in_length)
         storage_file_read(file, is_logged_in, is_logged_in_length) != is_logged_in_length)
     {
     {
         FURI_LOG_E(TAG, "Failed to read is_logged_in");
         FURI_LOG_E(TAG, "Failed to read is_logged_in");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
+        // storage_file_close(file);
+        // storage_file_free(file);
+        // furi_record_close(RECORD_STORAGE);
+        //  return false;
+    }
+    else
+    {
+        is_logged_in[is_logged_in_length - 1] = '\0'; // Ensure null-termination
     }
     }
-    is_logged_in[is_logged_in_length - 1] = '\0'; // Ensure null-termination
 
 
     storage_file_close(file);
     storage_file_close(file);
     storage_file_free(file);
     storage_file_free(file);