Skip to content

Commit

Permalink
Fixed mod delete action deleting too many mods
Browse files Browse the repository at this point in the history
  • Loading branch information
thommcgrath committed Dec 30, 2023
1 parent f3d9102 commit 2d080e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
32 changes: 17 additions & 15 deletions Project/Modules/PasswordStorage.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ Protected Module PasswordStorage
// Not found
End Try
#else
Var SavedPasswords As Dictionary = Preferences.SavedPasswords
Var SavedPasswords As JSONItem = Preferences.SavedPasswords

Var UserId As String
If Beacon.UUID.Validate(EmailOrUserId) Then
UserId = EmailOrUserId
Else
For Each Entry As DictionaryEntry In SavedPasswords
Var Keys() As String = SavedPasswords.Keys
For Each Key As String In Keys
Try
Var Dict As Dictionary = Entry.Value
If Dict.Lookup("email", "") = EmailOrUserId Then
UserId = Entry.Key
Var Child As JSONItem = SavedPasswords.Child(Key)
If Child.Lookup("email", "") = EmailOrUserId Then
UserId = Key
Exit
End If
Catch Err As RuntimeException
Expand Down Expand Up @@ -68,19 +69,20 @@ Protected Module PasswordStorage
Return ""
End Try
#else
Var PasswordData As Dictionary
Var SavedPasswords As Dictionary = Preferences.SavedPasswords
Var PasswordData As JSONItem
Var SavedPasswords As JSONItem = Preferences.SavedPasswords
Var UserId As String
If SavedPasswords.HasKey(EmailOrUserId) Then
PasswordData = SavedPasswords.Value(EmailOrUserId)
UserId = EmailOrUserId
Else
For Each Entry As DictionaryEntry In SavedPasswords
Var Keys() As String = SavedPasswords.Keys
For Each Key As String In Keys
Try
Var Dict As Dictionary = Entry.Value
If Dict.Lookup("email", "") = EmailOrUserId Then
UserId = Entry.Key
PasswordData = Dict
Var Child As JSONItem = SavedPasswords.Child(Key)
If Child.Lookup("email", "") = EmailOrUserId Then
UserId = Key
PasswordData = Child
Exit
End If
Catch Err As RuntimeException
Expand Down Expand Up @@ -121,12 +123,12 @@ Protected Module PasswordStorage
Return False
End Try
#else
Var PasswordData As New Dictionary
Var PasswordData As New JSONItem
PasswordData.Value("email") = Email
PasswordData.Value("password") = BeaconEncryption.SlowEncrypt(Email.Lowercase + " " + UserId.Lowercase + " " + Beacon.SystemAccountName + " " + Beacon.HardwareId, Password)

Var SavedPasswords As Dictionary = Preferences.SavedPasswords
SavedPasswords.Value(UserId) = PasswordData
Var SavedPasswords As JSONItem = Preferences.SavedPasswords
SavedPasswords.Child(UserId) = PasswordData
Preferences.SavedPasswords = SavedPasswords

Return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ End
End Try
Next
Next
Self.mModUUIDsToDelete.ResizeTo(-1)
End Sub
#tag EndEvent
#tag Event
Expand Down

0 comments on commit 2d080e3

Please sign in to comment.