/// <summary>
        /// if need, run this method for auto-login.
        /// </summary>
        /// <returns></returns>
        private async Task ClickSubmitButtonIfAuto()
        {
            Submit.IsEnabled   = false;
            SubitRing.IsActive = true;
            var user = EmailBox.Text;
            var pass = PasswordBox.Password;

            PasswordAndUserEncryption(ref user, ref pass);

            // set the abort button with keybord-focus, so that the vitual keyboad in the mobile device with disappear.
            Abort.Focus(FocusState.Keyboard);

            //await InsertLoginMessage(user, pass);
            var loginReturn = await PostLNULoginCallback(MainPage.LoginClient, user, pass);

            if (loginReturn != null)
            {
                CheckIfLoginSucceed(loginReturn);
            }
            else
            {
                ReportHelper.ReportAttention(GetUIString("Internet_Failed"));
                Submit.IsEnabled   = true;
                SubitRing.IsActive = false;
            }
        }
        /// <summary>
        /// if need, run this method for auto-login.
        /// </summary>
        /// <returns></returns>
        private async void ClickSubmitButtonIfAutoAsync()
        {
            Submit.IsEnabled   = false;
            SubitRing.IsActive = true;
            var user = EmailBox.Text;
            var pass = PasswordBox.Password;

            PasswordAndUserEncryption(user, pass);

            // set the abort button with keybord-focus, so that the vitual keyboad in the mobile device with disappear.
            Abort.Focus(FocusState.Keyboard);

            var result = await DoubanWebProcess.PostDoubanResponseAsync(
                path : "https://frodo.douban.com/service/auth2/token",
                host : "frodo.douban.com",
                reffer : null,
                content :
                new HttpFormUrlEncodedContent(new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("client_id", "0dad551ec0f84ed02907ff5c42e8ec70"),
                new KeyValuePair <string, string>("client_secret", "9e8bb54dc3288cdf"),
                new KeyValuePair <string, string>("redirect_uri", "frodo://app/oauth/callback/"),
                new KeyValuePair <string, string>("grant_type", "password"),
                new KeyValuePair <string, string>("username", user),
                new KeyValuePair <string, string>("password", pass),
                //new KeyValuePair<string, string>("apiKey","0dad551ec0f84ed02907ff5c42e8ec70"),
                new KeyValuePair <string, string>("os_rom", "android"),
            }),
                isMobileDevice : true);

            var tokenReturn = default(APITokenReturn);

            try {
                JObject jo = JObject.Parse(result);
                tokenReturn = new APITokenReturn {
                    AccessToken  = jo["access_token"].Value <string>(),
                    RefreshToken = jo["refresh_token"].Value <string>(),
                    ExpiresIn    = jo["expires_in"].Value <string>(),
                    UserId       = jo["douban_user_id"].Value <string>(),
                    UserName     = jo["douban_user_name"].Value <string>(),
                };
                MainLoginPopup.IsOpen = false;
                try {
                    await MainPage.SetUserStatusAsync(tokenReturn.UserId);

                    //await MainPage.SetUserStatusAsync("155845973");
                    NavigateToBase?.Invoke(
                        null,
                        null,
                        GetFrameInstance(FrameType.UserInfos),
                        GetPageType(NavigateType.UserInfo));
                } catch { /* Ignore. */ }
            } catch {
                ReportHelper.ReportAttentionAsync(GetUIString("LoginFailed"));
            }
        }
Пример #3
0
        /// <summary>
        /// if need, run this method for auto-login.
        /// </summary>
        /// <returns></returns>
        private async Task ClickSubmitButtonIfAuto()
        {
            Submit.IsEnabled   = false;
            SubitRing.IsActive = true;
            var user = EmailBox.Text;
            var pass = PasswordBox.Password;

            SettingsHelper.SaveSettingsValue(SettingsConstants.Email, user);
            PasswordEncryption(pass);

            // set the abort button with keybord-focus, so that the vitual keyboad in the mobile device with disappear.
            Abort.Focus(FocusState.Keyboard);
            await InsertLoginMessage(user, pass);
        }
Пример #4
0
        /// <summary>
        /// if need, run this method for auto-login.
        /// </summary>
        /// <returns></returns>
        private async void ClickSubmitButtonIfAutoAsync()
        {
            Submit.IsEnabled   = false;
            SubitRing.IsActive = true;
            var user = EmailBox.Text;
            var pass = PasswordBox.Password;

            PasswordAndUserEncryption(user, pass);

            // set the abort button with keybord-focus, so that the vitual keyboad in the mobile device with disappear.
            Abort.Focus(FocusState.Keyboard);

            await InsertLoginMessageAsync(user, pass, VerificationCodeBorder.Visibility == Visibility.Visible?VerificationCodeBox.Text : null, isAuto.Value);
        }