void Start()
        {
            mLoginController  = ArchitectureConfig.Architecture.LogicLayer.GetModule <ILoginController>();
            mUserInputManager = ArchitectureConfig.Architecture.LogicLayer.GetModule <IUserInputManager>();

            mLoginController.Login();

            MissionSystem m = new MissionSystem();

            m.SetmJumpCount();
        }
        public async void Can_Return_BadRequest_For_Null_Parameter()
        {
            _loginAttemptValidator.Setup(m => m.IsValid(It.IsAny<LoginAttempt>())).Returns(false);

            _loginController = new LoginController(_userRepository.Object, _jwtProvider.Object, _dateProvider.Object, _loginAttemptValidator.Object);

            IHttpActionResult response = await _loginController.Login(null);

            Assert.IsInstanceOf<BadRequestErrorMessageResult>(response);
            _userRepository.Verify(m => m.GetAsync(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
            _jwtProvider.Verify(m => m.CreateJwt(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<DateTime>()), Times.Never());
        }
        public async void Can_Return_Token_For_Valid_Credentials()
        {
            _loginAttemptValidator.Setup(m => m.IsValid(It.IsAny<LoginAttempt>())).Returns(true);

            _loginController = new LoginController(_userRepository.Object, _jwtProvider.Object, _dateProvider.Object, _loginAttemptValidator.Object);

            IHttpActionResult response = await _loginController.Login(new LoginAttempt("TEST", "TEST"));

            Assert.IsInstanceOf<OkNegotiatedContentResult<string>>(response);
            Assert.AreEqual("TEST", ((OkNegotiatedContentResult<string>)response).Content);
            _userRepository.Verify(m => m.GetAsync(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
            _jwtProvider.Verify(m => m.CreateJwt(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<DateTime>()));
        }
Exemplo n.º 4
0
        public async void Login()
        {
            var result = await _loginController.Login(_userName, _password, _captchaValue);

            switch (result.ResultStatus)
            {
            case ResultType.WrongUserNameOrPassword:
                Error = "نام کاربری یا رمز عبور اشتباه است";
                RefreshCaptcha();
                break;

            case ResultType.WrongCaptcha:
                Error = "کد تصویر اشتباه است";
                RefreshCaptcha();
                break;

            case ResultType.ConnectionProblem:
                Error = "خطا در اتصال";
                break;

            default:
            {
                Student newStudent = result.Content;
                _studentRepository.Insert(newStudent);

                _settings.UserName    = newStudent.UserName;
                _settings.FullName    = newStudent.FullName;
                _settings.StudentCode = newStudent.StudentCode;
                _settings.Cookies     = string.Join(";", result.Content2.Select(p => $"{p.Name}={p.Value}"));
                _settings.FirstTime   = false;

                _settings.Save();

                _eventAggregator.PublishOnUIThread(newStudent.UserName);
                break;
            }
            }
        }
Exemplo n.º 5
0
 private void loginBtn_Click(object sender, EventArgs e)
 {
     _loginController.Login(userNameTE.Text, passwordTE.Text);
 }