Пример #1
0
        public static LoginAccount GetValidLogin(string username, string password)
        {
            LoginAccount loginAccount;

            if (_loginAccountList.TryGetValue(username, out loginAccount) && SecurePasswordHasher.Verify(password, loginAccount.Password))
            {
                return(loginAccount);
            }
            return(null);
        }
Пример #2
0
        public static bool TryUpdateLogin(string Username, string newPassword, string newPlayername, string oldPassword, string oldPlayername)
        {
            LoginAccount updateableLoginAccount = new LoginAccount(Username, newPassword, newPlayername);
            //TryUpdate gör inte djup jämförelse (går troligtvis att lägga till stöd för compare i LoginAccount)
            LoginAccount oldLoginAccount;

            if (_loginAccountList.TryGetValue(Username, out oldLoginAccount) && SecurePasswordHasher.Verify(oldPassword, oldLoginAccount.Password) && oldLoginAccount.Playername == oldPlayername)
            {
                return(_loginAccountList.TryUpdate(Username, updateableLoginAccount, oldLoginAccount));
            }
            else
            {
                return(false);
            }
        }