#Dynamically update the contentProtected field in the tauri config file

3 messages · Page 1 of 1 (latest)

blissful badger
#

Is there any way to dynamically update the tauri conf file based on certain conditions(depending what kind of user has logged in a dashboard app). I want to update the contentProtected field to stop users from capturing the app. is there any way? Thanks in advance

hushed moth
#

I'm assuming the dashboard and the login are part of the same app. The recommended way would be to put the login window in your tauri.conf.json file and then use a #[tauri::command] to create the main content window when the user has successfully logged in. That way, you already know what kind of user it is and can set the content_protected field on the window before it is created.

#

If the login isn't part of the same app, you can set it before you even create the Tauri runtime.

let mut tauri_context = tauri::generate_context!();
if true {
  for window in tauri_context.config_mut().tauri.windows.iter_mut() {
    window.content_protected = true;
  }
}