Beispiel #1
0
        public void Login_Call_Busy_Method_2_Times()
        {
            _sut.Login(GetValidUser().Key, GetValidUser().Value);

            _view.Verify(m => m.Busy(true), Times.Once);
            _view.Verify(m => m.Busy(false), Times.Once);
        }
        public void OnLogin(string code)
        {
            dialog.Show();

            var cientId       = Resources.GetString(Resource.String.ClientId);
            var clientSercret = Resources.GetString(Resource.String.ClientSercret);
            var grant_type    = "authorization_code";
            var redirect_uri  = "https://oauth.cnblogs.com/auth/callback";

            var content = string.Format("client_id={0}&client_secret={1}&grant_type={2}&redirect_uri={3}&code={4}", cientId, clientSercret, grant_type, redirect_uri, code);

            loginPresenter.Login(TokenShared.GetAccessToken(this), content);
        }
        /// <summary>
        /// Execute login command
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static ICommandResult Login(IEntity entity)
        {
            if (entity.GetType() == typeof(LoginData))
            {
                ILoginPresenter presenter = ServiceLocator.GetObject <ILoginPresenter>(ServiceLocator.GetObject <ILoginView>());
                var             login     = (LoginData)entity;

                presenter.Login(null, ref login);
                entity = login;

                return(presenter);
            }

            throw new ArgumentOutOfRangeException("entity", string.Format("{0} Entity is not supported.", entity.GetType()));
        }
Beispiel #4
0
        public void OnClick(View v)
        {
            switch (v.Id)
            {
            case Resource.Id.login:
                var account  = editAccount.Text;
                var password = editPassword.Text;
                if (account.Trim() == "")
                {
                    Toast.MakeText(this, Resources.GetString(Resource.String.need_account), ToastLength.Short).Show();
                    return;
                }
                if (password.Trim() == "")
                {
                    Toast.MakeText(this, Resources.GetString(Resource.String.need_password), ToastLength.Short).Show();
                    return;
                }
                var publicKey = Resources.GetString(Resource.String.PublicKey);
                if (publicKey == "")
                {
                    Toast.MakeText(this, Resources.GetString(Resource.String.publicKey_error), ToastLength.Short).Show();
                    return;
                }
                RSAUtils rsaUtils = new RSAUtils(publicKey);
                dialog.SetMessage(Resources.GetString(Resource.String.logining));
                dialog.Show();

                var basic = Square.OkHttp3.Credentials.Basic(Resources.GetString(Resource.String.ClientId), Resources.GetString(Resource.String.ClientSercret));

                loginPresenter.Login(TokenShared.GetAccessToken(this), basic, rsaUtils.Encrypt(account), rsaUtils.Encrypt(password));
                break;

            default:
                InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(editPassword.WindowToken, 0);
                SetResult(Result.Canceled);
                ActivityCompat.FinishAfterTransition(this);
                break;
            }
        }
 protected void buttonLoginClick(object sender, EventArgs e)
 {
     Log.Debug("buttonLoginClick");
     _presenter.Login();
 }