Connoisseurs, can you have any idea how to implement this?

The user starts the program, the authorization window opens. If the user entered the username and password, and also clicked "remember me", then the config is saved with the user parameters, but if another user wants to enter his data and does not click "remember me" - the program will still load the config with the previously saved data , even if the user is logged in under a different name.

My version was this: Suppose I started the program and saw the saved data in the authorization window, instead I entered my own and unchecked the “remember me” checkbox - at that moment the program should create a copy of the configuration file and save me there, then work with it file, but there is a lot of inconvenience.

Are there any options for how best to do this?

  • It is not clear why saving a config file to the "remember mine" button, when it can be done completely unobtrusively. A config, even a personal one, usually exists independently of some buttons. And the original and the only correct meaning of “remembering a moment” is that the next time you start the program does not ask for any username and password, but immediately automatically starts under the user you remember. - Sergey
  • In desktop applications, this is called "remember password", "autologin". In browser-based web applications, neither the login nor the password is remembered, but instead a cookie is issued, which the next time the browser presents instead of the login. Technically, "remember the password" is no longer called, so they came up with "remember the mine." And then some of this term “remember mine” began to invent a completely crazy functionality instead of the original one. - Sergey
  • If the user clicked "remember", then his data is saved to the config, but then I have a bug - if I enter other data - they will also be checked, the program will let the user in and load the conf that was already from another user. In this case, the program should, in any case, load the config, and it has a static name .. Is there any option to fix this? - Elizabeth
  • What prevents you from making a dynamic config name? String Konfig = "konfig_" + userId + ".konfig"; - Sergey
  • You see, I have a condition in app.xaml.cs — if there is no config — to create it (with default name), then a login window opens and there is another check in it — if there is a config, then load the login and password from it into the boxes . And if the new user does not deem to click "save account" but simply enters - what to do in this case? - create a new config with the name of the new user and load it? And what to do with it at the end of the program? It is necessary to get rid of it so that the program loads the original config, does it not? - Elizabeth

1 answer 1

If we are talking about the functionality of "remember me", it makes sense to do this:

  1. In user-level settings, put the properties that describe the username of the saved user and his password (or, possibly, a password hash, this is what your security model dictates). In the beginning they are empty. Separate configuration files are redundant.
  2. When starting the program, if there is a saved username and password, use them silently, without displaying a dialog box.
  3. If nothing is saved (or only the login is saved), show the login and password input dialog. Login field fill in advance with a value if it is available.
    • If the dialog is closed with the OK button, remember the new login in settings. If the user at the same time put the checkbox "remember me", then remember the password, otherwise reset it to null.
    • If the dialogue is closed differently, just do not change anything, but do not let the user go further: he is not authorized. (Perhaps a more reasonable UI is needed for this case.)
  4. In the application, make a logout button that will reset the saved password and open the login dialog again.
  • Thanks, I will try! - Elizaveta
  • @ Elizabeth: Please! Hope that helps! - VladD