Improving the login process
In the process of user management, we may need to add new users or remove outdated users from the system. For our app, it only allows one user to log in at a time. To support this feature, we can implement a class using the singleton pattern. Alternatively, we can implement a class and utilize dependency injection to have a similar effect on the singleton pattern. For instance, we can create a LoginService
class that inherits from the User
class, as demonstrated in Listing 5.4:
using System.Diagnostics;
using PassXYZLib;
namespace PassXYZ.Vault.Services;
public class LoginService : PxUser { //(1)
private IUserService<User> _userService;
private const string PrivacyNotice = "Privacy Notice";
public static bool IsPrivacyNoticeAccepted {
get => Preferences.Get(PrivacyNotice, false);
set => Preferences.Set(PrivacyNotice, value);
}
public LoginService(IUserService<User> userService...