示例#1
0
        public User ReadUser()
        {
            Console.WriteLine("Pulling user info...");
            var user = new User();
            try {
                if (!File.Exists(authPath))
                    return user;
                string[] text = File.ReadAllLines(authPath);
                if (text.Length==0)
                    return user;

                var encryptedNickName = text[0];
                user.NickName = EncryptionManager.Decrypt(encryptedNickName);

                var encryptedFirstName = text[1];
                user.FirstName = EncryptionManager.Decrypt(encryptedFirstName);

                var encryptedLastName = text[2];
                user.LastName = EncryptionManager.Decrypt(encryptedLastName);

                var encryptedPassword = text[3];
                user.Password = EncryptionManager.Decrypt(encryptedPassword);

                return user;

            } catch (Exception){
                return null;
            }
        }
示例#2
0
        private void _HttpGetCompleted(List<string> errors, string result)
        {
            if (errors != null)
                OnLoginCompleted(errors, null);
            else {
                _loggedInUser = User.BuildFromJson(result);
                if (!string.IsNullOrEmpty(_loggedInUser.NickName))
                    _loggedInUser.Password = _loginPassword;

                OnLoginCompleted(null, _loggedInUser);
            }
        }
示例#3
0
        public void SaveUser(User user)
        {
            try {
                Console.WriteLine("Saving user info...");
                if (user == null)
                    user = new User();

                var encryptedNickName = EncryptionManager.Encrypt(user.NickName);
                var encryptedFirstName = EncryptionManager.Encrypt(user.FirstName);
                var encryptedLastName = EncryptionManager.Encrypt(user.LastName);
                var encryptedPassword = EncryptionManager.Encrypt(user.Password);

                File.WriteAllText(authPath, String.Format("{0}\n{1}\n{2}\n{3}",
                    encryptedNickName,
                    encryptedFirstName,
                    encryptedLastName,
                    encryptedPassword));
            } catch (Exception){}
        }
示例#4
0
 public void Logout()
 {
     var user = new User();
     Repository.User = user;
     UserStore.SaveUser(user);
     _uiClient.ApplicationStartUpMode(AppMode.Login);
 }
示例#5
0
        private void _LoginCompleted(List<string> errors, User user)
        {
            AppMode mode;
            if (errors != null) {
                ShowMessage(Constants.APP_TITLE, errors[0]);
                mode = AppMode.Login;
            }
            else {
                Console.WriteLine("Login success!");
                UserStore.SaveUser(user);
                Repository.User = user; //.Sanitize(); //so we dont keep pwd in memory
                mode = user.Newbie ? AppMode.Newbie : AppMode.Tabs;
            }

            OnNetworkUsageEnded();
            _uiClient.ApplicationStartUpMode(mode);
        }