📜 ⬆️ ⬇️

Where to store user settings

Once, at the time of permissiveness and Chaos, programs stored user settings somewhere. Many kept one copy of the settings for the entire system. Over time, all OSs acquired normal user profiles, began to restrict access to system folders, and all programmers were taught to keep their settings in the folder (branch) of their profile. It would seem, on that and a fairy end. But no. There are cases when this approach does not work. I will demonstrate this by the example of an error (namely, an architectural error, and not a banal bug due to a typo) in one of Google’s applications.

We are talking about the service Google Music. As you know, you can listen / download music in this service through the WEB interface, but you can upload it to the server only from the special Google Music Manager application. After installation and login it will ask you to specify the folders from where you would like to upload music to the Google cloud. Choose a couple of pieces:



The program will automatically download files. At the end, it will say that everything has been successfully uploaded. Well, ok, so far so good.
')
Now we will log in and log in under another Google Music account. And attention, what we see:



The same folders are already registered in this account and moreover, the songs are already being loaded into another account! All this happened by itself, without any action on our part. For those who have not yet understood the entire epic of the file, I will give an analogy: you come to visit a friend, ask for his computer to check mail, log in with your account - and suddenly letters from your friend's mailbox begin to get into your mailbox. Cool? Cool.

Why did this happen? The answer is simple:



Google Music Manager stores the settings of shared folders in a user profile in the registry. When relogin in the program settings do not change. The fact that one user may have several accounts or the situation “I log in on someone else’s computer” is not taken into account at all. And this is a bug.

Conclusion


If your application asks the user for a login \ password and connects somewhere, you should provide for storing its settings not in the OS user profile, but in the user's own user profile files. OS users! = Users of external services.

Source: https://habr.com/ru/post/137322/


All Articles