public void CreateUser(long chatId, string password) { ISecureManager secureManager = ModulesManager.GetSecureManager(); if (IsUserExist(chatId)) { LogoutUser(chatId); using (UsersContext db = new UsersContext()) { UserModel userModel = db.Users .Where(user => user.ChatId == chatId) .First(); userModel.HashPassword = secureManager.CalculateHash(password); db.SaveChanges(); } } else { using (UsersContext db = new UsersContext()) { UserModel userModel = new UserModel { ChatId = chatId, HashPassword = secureManager.CalculateHash(password) }; db.Users.Add(userModel); db.SaveChanges(); } } }
internal UserLocal(long chatId, string password) { if (string.IsNullOrEmpty(password)) { throw new ArgumentException("Password cannot be null"); } ISecureManager secureManager = ModulesManager.GetSecureManager(); ChatId = chatId; IsAuthorized = false; hashPassword = secureManager.CalculateHash(password); EncryptedPassword = null; }