Skip to content

Commit

Permalink
create registry migration - delete deprecated settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Sep 17, 2023
1 parent a69ee3f commit abbc3c0
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion source/Main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ sub Main (args as dynamic) as void
end if

' Only show the Whats New popup the first time a user runs a new client version.
if m.global.app.version <> get_setting("LastRunVersion")
appLastRunVersion = get_setting("LastRunVersion")
if m.global.app.version <> appLastRunVersion
' Ensure the user hasn't disabled Whats New popups
if m.global.session.user.settings["load.allowwhatsnew"] = true
set_setting("LastRunVersion", m.global.app.version)
Expand All @@ -72,6 +73,34 @@ sub Main (args as dynamic) as void
end if
end if

' Registry migrations
if isValid(appLastRunVersion) and not versionChecker(appLastRunVersion, "1.7.0")
' last app version used less than 1.7.0
' no longer saving raw password to registry
' auth token and username are now stored in user settings and not global settings
print "Running 1.7.0 registry migrations"
' remove global settings
unset_setting("token")
unset_setting("username")
unset_setting("password")
' remove user settings
unset_user_setting("password")
' remove saved credentials from saved_servers
saved = get_setting("saved_servers")
if isValid(saved)
savedServers = ParseJson(saved)
if isValid(savedServers.serverList) and savedServers.serverList.Count() > 0
newServers = { serverList: [] }
for each item in savedServers.serverList
item.Delete("username")
item.Delete("password")
newServers.serverList.Push(item)
end for
set_setting("saved_servers", FormatJson(newServers))
end if
end if
end if

' Handle input messages
input = CreateObject("roInput")
input.SetMessagePort(m.port)
Expand Down

0 comments on commit abbc3c0

Please sign in to comment.