private void SaveUser(UserBean loginUser)
        {
            var userList = LoadUserList().Where(user => user.id != loginUser.id).ToList();
            userList.Insert(0, loginUser);

            string json = JsonConvert.SerializeObject(userList);
            FileHelper.WriteStringToFile(USERFILE, json);
        }
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            LoginButton.IsEnabled = false;
            var isLogin = false;
            UserBean loginUser = null;
            
            _client.clearCookie();

            if (!UserSelector.IsEmpty && UserSelector.SelectedUser.fingerprint != null)
            {
                var fingerprint = UserSelector.SelectedUser.fingerprint;
                _client.addCookie(HOST, FINGERPRINT, fingerprint);
            }

            try
            {
                loginUser = await Task.Run(() => {
                    _client.Get(HOST);

                    var url = String.Format("{0}/signin", HOST);
                    var result = _client.Get(url);

                    var data = JsonConvert.DeserializeObject<SignInInfo>(result);

                    if (data.result)
                    {
                        isLogin = true;
                        return data.loginUser;
                    }
                    return null;
                });

                if (!isLogin)
                {
                    var email = EmailBox.Text;
                    var password = PasswordBox.Password;

                    if (!"".Equals(email) && !"".Equals(password))
                    {
                        var salt = await Task.Run(() => {
                            var url = String.Format("{0}/signin/salt", HOST);
                            var result = _client.Get(url);

                            var data = JsonConvert.DeserializeObject<SignInInfo>(result);
                            return data.salt;
                        });

                        if (salt != null)
                        {
                            loginUser = await Task.Run(() => {
                                var url = String.Format("{0}/signin", HOST);
                                var result = _client.Post(url, new Dictionary<string, string>() {
                                    { "email" , email },
                                    { "password", CryptHelper.Md5Hex(CryptHelper.Md5Hex(password) + salt) },
                                    { "autoLogin", "1" }
                                });

                                var data = JsonConvert.DeserializeObject<SignInInfo>(result);

                                if (data.result)
                                {
                                    isLogin = true;
                                    return data.loginUser;
                                }
                                return null;
                            });
                        }
                    }
                }
            }
            catch
            {
                isLogin = false;
            }
            finally
            {
                LoginButton.IsEnabled = true;

                if (isLogin)
                {

                    Cookie cookie = _client.findCookie(HOST, FINGERPRINT);
                    if (cookie != null)
                    {
                        loginUser.fingerprint = cookie.Value;
                        if (log.IsDebugEnabled)
                        {
                            log.Debug("fingerprint = " + loginUser.fingerprint);
                        }
                    }

                    _viewModel.LoginUser = loginUser;
                    _viewModel.IsLogin = true;

                    StartMusicListPanel();

                    var userId = loginUser.id;
                    //download user avatar
                    await Task.Run(() => {
                        DownloadUserAvatar(userId);
                    });
                    
                    ImageHelper.LoadImage(UserAvatarButtonImage, String.Format("cache/u{0}_avatar.jpg", userId), "Assert/ic_account_circle_white_48dp.png");

                    await Task.Run(() => {
                        var newUser = new UserBean();
                        newUser.id = loginUser.id;
                        newUser.nickname = loginUser.nickname;
                        newUser.fingerprint = loginUser.fingerprint;
                        
                        SaveUser(newUser);
                    });
                }
            }
        }