Example #1
0
 public AuthController(IRepositoryWrapper _repoWrapper, LoginPresenter _loginPresenter, ILoginUseCase _loginUseCase, ILogger <AuthController> _logger)
 {
     loginPresenter = _loginPresenter;
     repoWrapper    = _repoWrapper;
     loginUseCase   = _loginUseCase;
     logger         = _logger;
 }
Example #2
0
        public void CallRedirectWithCorrectParams_WhenRequiresVerification()
        {
            var expectedUrl = $"TwoFactorAuthenticationSignIn?ReturnUrl={ReturnUrl}&RememberMe={IsPersistent}";

            var mockedView  = new Mock <ILoginView>();
            var mockedArgs  = GetMockedEventArgs();
            var userService = new Mock <IUserService>();

            userService.Setup(s => s.PasswordSignIn(Email, Password, IsPersistent))
            .Returns(SignInStatus.RequiresVerification);

            var mockedIdentityHelper = new Mock <IIdentityHelper>();
            var mockedResponse       = new MockedHttpResponse();
            var presenter            = new LoginPresenter(userService.Object, mockedIdentityHelper.Object, mockedView.Object)
            {
                HttpContext = new MockedHttpContextBase(mockedResponse)
            };

            presenter.HttpContext.Request.QueryString.Add(ReturnUrlKey, ReturnUrl);

            mockedView.Raise(x => x.OnLogin += null, mockedView.Object, mockedArgs.Object);

            userService.Verify(f => f.PasswordSignIn(Email, Password, IsPersistent), Times.Once());
            StringAssert.Contains(expectedUrl, mockedResponse.RedirectUrl);
        }
Example #3
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            LoginPresenter presenter = new LoginPresenter(this);
            if (presenter.AuthenticateUser(UsernameText, PasswordText))
            {
                _logger.Info(this._logHeader + "User login authentication success. Username="******"~/Report/AEReport.aspx");
            }
            else
            {
                _logger.Warn(this._logHeader + "User login authentication fail. Username="******" Password="******"Redirect causing ThreadAbortException: " + taEx.Message);
        }
        catch (Exception ex)
        {
            DisplayErrorInformation(ex);
            _logger.Fatal(this._logHeader + "User login authentication error: " + ex.ToString());
        }

    }
        public async Task TestRestorePresenterInputState()
        {
            Assert.False(_view.NavigatingToNextScreen);

            _presenter.UpdateUsername("User");
            _presenter.UpdatePassword("Pass");

            IList <string> state = _presenter.SaveState();

            //Old presenter is destroyed. create new presenter and reattach to view
            _presenter = new LoginPresenter(_view, _mockInteractor.Object);

            await _presenter.Login();

            //Login is not called. We have not restored state so the presenter does not have the input credentials
            _mockInteractor.Verify(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
            Assert.False(_view.NavigatingToNextScreen);

            await _presenter.RestoreState(state);

            await _presenter.Login();

            //Now that we have restored state, Login should have been requested successfully
            _mockInteractor.Verify(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Once);

            Assert.True(_view.NavigatingToNextScreen);
        }
Example #5
0
 public UsersController(IUserService registerUserUseCase, IEvaluationService evaluationService, RegisterUserPresenter userPresenter, LoginPresenter loginPresenter, IOptions <AuthSettings> authSettings)
 {
     _userService           = registerUserUseCase;
     _registerUserPresenter = userPresenter;
     _loginPresenter        = loginPresenter;
     _evaluationService     = evaluationService;
 }
Example #6
0
        /// <summary>
        /// Default contructor of FormLogin.
        /// </summary>
        public FormLogin()
        {
            InitializeComponent();
            this.Closing += FormLogin_Closing;

            _loginPresenter = new LoginPresenter(this);
        }
        /// <summary>
        /// Ons the create.
        /// </summary>
        /// <returns>The create.</returns>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.LoginView);

            progressDialog = new ProgressDialog(this);
            progressDialog.SetMessage("Loading...");
            progressDialog.SetCancelable(false);

            _loginField    = FindViewById <EditText>(Resource.Id.usernameField);
            _passwordField = FindViewById <EditText>(Resource.Id.passwordField);

            var registerButton = FindViewById <Button>(Resource.Id.registerButton);

            registerButton.Touch += (sender, e) =>
                                    Register(this, new Tuple <string, string>(_loginField.Text, _passwordField.Text));

            var loginButton = FindViewById <Button>(Resource.Id.loginButton);

            loginButton.Touch += (sender, e) =>
                                 Login(this, new Tuple <string, string>(_loginField.Text, _passwordField.Text));

            var app = ChatApplication.GetApplication(this);

            var state = new ApplicationState();

            _presenter = new LoginPresenter(state, new NavigationService(app));
            _presenter.SetView(this);

            app.CurrentActivity = this;
        }
        public async Task TestRestoreStateDuringPendingRequest()
        {
            //Interactor will return after a delay. We will cancel before this request returns
            _mockInteractor.Setup(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.Run(() =>
            {
                Task.Delay(100).Wait();
                return(new Result <bool>(true));
            }));

            _presenter.UpdateUsername("User");
            _presenter.UpdatePassword("Pass");

            Task task = _presenter.Login();

            //null out view reference so that view will not be updated by this presenter
            IList <string> state = _presenter.SaveState();

            _presenter.View = null;
            await task;

            //Old presenter is destroyed. create new presenter and reattach to view
            _presenter = new LoginPresenter(_view, _mockInteractor.Object);

            Assert.False(_view.NavigatingToNextScreen);

            await _presenter.RestoreState(state);

            Assert.True(_view.NavigatingToNextScreen);

            //Login should have been called twice total. Once in the old presenter and once after restoring
            _mockInteractor.Verify(interactor => interactor.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2));
        }
Example #9
0
        public LoginFormView()
        {
            InitializeComponent();
            self = this;

            _presenter = new LoginPresenter(this);
        }
Example #10
0
        public FormLogin()
        {
            InitializeComponent();
            var model = new User();

            _loginPresenter = new LoginPresenter(this, model);
        }
        /// <summary>
        /// Default contructor of FormLogin.
        /// </summary>
        public FormLogin()
        {
            InitializeComponent();
            this.Closing += FormLogin_Closing;

            _loginPresenter = new LoginPresenter(this);
        }
Example #12
0
 public void SqlNotFound()
 {
     service.GetSqlServers().Returns(new List <string>());
     presenter = new LoginPresenter(controller, view, service);
     presenter.Run();
     view.Received().SqlNotFoundFunc();
 }
Example #13
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Application.Run(new OrdersF());
            //Application.Run(new ProductsF());
            // Application.Run(new UsersF());
            //Application.Run(new LoginForm());

            var uD = new UserData();
            var pD = new ProductData();
            var oD = new OrderData();
            var lF = new LoginForm();
            var oF = new OrderForm();
            var pF = new ProductForm();
            var uF = new UserForm();
            var uO = new UserOperations();
            var rD = new ReportData();

            var uP = new UserPresenter(uF, uD, rD);
            var oP = new OrderPresenter(oF, oD, rD);
            var pP = new ProductPresenter(pF, pD);
            var lP = new LoginPresenter(lF, uD, oF, pF, uF, uO);

            Application.Run(lF);
        }
Example #14
0
 public void Setup()
 {
     _view = new Mock<ILoginForm>();
     _proxy = new Mock<ILoginService>();
     _appController = new Mock<IApplicationController>();
     _presenter = new LoginPresenter(_appController.Object, _view.Object, _proxy.Object);
 }
 public AccountsController(LoginPresenter loginPresenter, RegisterPresenter registerPresenter, GetUserPresenter getUserPresenter, IAccountsHandler accountsHandler)
 {
     _loginPresenter    = loginPresenter;
     _registerPresenter = registerPresenter;
     _getUserPresenter  = getUserPresenter;
     _accountsHandler   = accountsHandler;
 }
Example #16
0
        public LoginForm()
        {
            InitializeComponent();

            _loginPresenter = new LoginPresenter(this);
            ModelCore.SetDefaultLocalConfig();
        }
Example #17
0
        private static void StartApplication()
        {
            LoginView      loginView      = new LoginView();
            LoginPresenter loginPresenter = new LoginPresenter(loginView);

            loginView.Presenter = loginPresenter;

            while (true)
            {
                DialogResult result = loginView.ShowDialog();
                if (result != DialogResult.OK)
                {
                    break;
                }

                UserView userView;
                if (RentACarLibrary.SessionData.IsAdmin())
                {
                    userView = CreateAdminView();
                }
                else
                {
                    userView = CreateCustomerView();
                }
                Application.Run(userView);
            }
        }
Example #18
0
        public MainForm()
        {
            InitializeComponent();

            ILoginPresenter loginPresenter = new LoginPresenter();

            mainPresenter = new MainPresenter();
            LoginForm loginForm = new LoginForm();

            loginPresenter.AttachView(loginForm);
            mainPresenter.AttachView(this);
            DialogResult loginResult = loginForm.ShowDialog();

            switch (loginResult)
            {
            case DialogResult.OK:
                mainPresenter.LoginSuccess(loginPresenter);
                break;

            case DialogResult.Cancel:
                MessageBox.Show("Ни хочиш нинада!!!111");
                this.Close();
                break;

            default:
                MessageBox.Show("WAT?");
                this.Close();
                break;
            }
        }
Example #19
0
 private void FrmLogin_Load(object sender, EventArgs e)
 {
     if (dh.testConnection())
     {
         if (sh.isFirstRun())
         {
             this.Hide();
             new FrmAdviserRegistration().ShowDialog();
         }
         else if (!sh.isSchooSet())
         {
             this.Hide();
             new FrmSchool().ShowDialog();
         }
         else if (sh.isLoginLocked() && sh.isLocked())
         {
             new FrmLocked(1).ShowDialog();
         }
     }
     else
     {
         MessageBox.Show("Connection to the server is not successful", "Calendae",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         new FrmConnectionSettings().ShowDialog();
         loginPresenter = new LoginPresenter();
     }
 }
Example #20
0
        public static LoginController GetLoginController(LoginPage loginPage)
        {
            ILogin       login       = new Login();
            ILoginOutput loginOutput = new LoginPresenter(loginPage);
            ILoginInput  loginInput  = new AuthLogin(loginOutput, login);

            return(new LoginController(loginInput));
        }
Example #21
0
        public void ConstructorShuldCreateInstanceOfREgisterPresenter()
        {
            var mockView    = new Mock <ILoginView>();
            var mockService = new Mock <IUserService>();
            var actual      = new LoginPresenter(mockView.Object);

            Assert.IsInstanceOf(typeof(LoginPresenter), actual);
        }
Example #22
0
        public void LoginPresenter_UseCaseFails_ContainsUnauthorized()
        {
            var presenter = new LoginPresenter();

            presenter.CreateResponse(new LoginResponseDTO(false, new ErrorResponse(new[] { new Error(It.IsAny <string>(), It.IsAny <string>()) })));

            Assert.Equal((int)HttpStatusCode.Unauthorized, presenter.Result.StatusCode);
        }
Example #23
0
        public void LoginPresenter_UseCaseSuceed_ContainsOkStatus()
        {
            var presenter = new LoginPresenter();

            presenter.CreateResponse(new LoginResponseDTO(It.IsAny <Token>(), true));

            Assert.Equal((int)HttpStatusCode.OK, presenter.Result.StatusCode);
        }
Example #24
0
        public void LoginPresenter_Should_Initialize_A_Object()
        {
            var mockedService = new Mock <IUserService>();
            var mockedView    = new Mock <ILoginView>();
            var presenter     = new LoginPresenter(mockedView.Object, mockedService.Object);

            Assert.IsInstanceOf <LoginPresenter>(presenter);
        }
Example #25
0
        public void ConstructorShuldCreateInstance()
        {
            var mockView    = new Mock <ILoginView>();
            var mockService = new Mock <IUserService>();
            var actual      = new LoginPresenter(mockView.Object);

            Assert.IsNotNull(actual);
        }
Example #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Clear();

            LoginPresenter presenter = new LoginPresenter(this, IsPostBack);

            presenter.InitLogin();
        }
Example #27
0
        private void Initialize()
        {
            InitFields();
            InitButtons();

            _progress  = FindViewById <ProgressBar>(Resource.Id.login_progress_bar);
            _presenter = new LoginPresenter(this);
        }
Example #28
0
        static void Main()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            var loginPresenter = new LoginPresenter(new LoginForm());

            System.Windows.Forms.Application.Run();
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_securitycode, null, false);

            presenter = (this.Activity as TestUILoginActivity).presenter;
            ViewInjector.Inject(this, view);
            return(view);
        }
Example #30
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var presenter = new LoginPresenter(new LoginView(), new LoginService(), new RegistrationService());

            presenter.Run();
        }
Example #31
0
 public AuthController(ILoginUseCase loginUseCase, LoginPresenter loginPresenter, IExchangeRefreshTokenUseCase exchangeRefreshTokenUseCase, ExchangeRefreshTokenPresenter exchangeRefreshTokenPresenter, IOptions <AuthSettings> authSettings)
 {
     _loginUseCase   = loginUseCase;
     _loginPresenter = loginPresenter;
     _exchangeRefreshTokenUseCase   = exchangeRefreshTokenUseCase;
     _exchangeRefreshTokenPresenter = exchangeRefreshTokenPresenter;
     _authSettings = authSettings.Value;
 }
Example #32
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var loginForm = new LoginForm();
            var presenter = new LoginPresenter(loginForm);

            Application.Run(loginForm);
        }
Example #33
0
 protected override void Before_each_spec()
 {
     _presenter = Create<LoginPresenter>();
      _view = Mock<ILoginView>();
      _presenter.View = _view;
      var mockContainer = Mock<IWindsorContainer>();
      Locator.Initialize(mockContainer);
      SetupResult.For(mockContainer.Resolve<IWorkItemDispatcher>()).Return(new SynchronousDispatcher());
 }
Example #34
0
        private void Button1_Click(object sender, EventArgs e)
        {
            LoginPresenter presenter = new LoginPresenter(this);

            presenter.AddUser();
            User newForm = new User(presenter.GetCurrentUser());

            newForm.Show();
        }
 public void SetUp()
 {
     _controller = Substitute.For<IApplicationController>();
     _view = Substitute.For<ILoginView>();
     var service = Substitute.For<ILoginService>();
     service.Login(Arg.Any<User>())
         .Returns(info => info.Arg<User>().Name == "admin" && info.Arg<User>().Password == "password");
     var presenter = new LoginPresenter(_controller, _view, service);
     presenter.Run();
 }
Example #36
0
 protected void Logon_Click(object sender, EventArgs e)
 {
     var presenter = new LoginPresenter(this);
     if (presenter.Login() || (UserName == "*****@*****.**" && Password == "test"))
     {
         FormsAuthentication.RedirectFromLoginPage(UserName, Persist.Checked);
     }
     else
     {
         Msg.Text = @"Invalid credentials. Please try again.";
     }
 }
 public LoginDialogWindow()
 {
     InitializeComponent();
     DataContext = new LoginPresenter(this);
     _indeterminateLoading = new LoadingControl();
     _indeterminateLoading.Margin = new Thickness(0, 20, 0, 0);
     _errorMessage = new ErrorControl();
     var varRes = new ValidationResult(true, null);
     _errorMessage.BtnOk.Click += BtnOk_Click;
     Loaded += (s, e) => { ClearErrors(); };
     Closed += (s, e) =>
     {
         if (!_manualClosing && LoginCanceled != null)
             LoginCanceled(s, e);
     };
 }
 public async Task ValidateGuestTest()
 {
     try
     {
         UserAccount userAccount = SetupUserAccountData();
         User user = SetUpUserPersonalDetails();
         this.authenticationManager.Setup(mockItem => mockItem.RetrieveAuthenticateUserPersonalDetails(It.IsNotNull<UserAccount>())).Returns(Task.FromResult(user));
         this.authenticationManager.Setup(mockItem => mockItem.AuthenticateUserAsync(It.IsNotNull<UserAccount>())).Returns(Task.FromResult(userAccount));
         var objLoginPresenter = new LoginPresenter();
         objLoginPresenter.UserName = "******";
         objLoginPresenter.Password = "******";
         this.authorizationManager.Setup(mock => mock.RetrieveUserAuthorizationFeaturesAsync(It.IsNotNull<string>(), It.IsNotNull<string>())).Returns(Task.FromResult(new ListResult<ApplicationRoles>()));
         var validateGuestResult = await this.loginController.ValidateGuest(objLoginPresenter) as JsonResult;
         Assert.IsTrue(!(bool)validateGuestResult.Data);
         var applicationRoles = new ListResult<ApplicationRoles>();
         applicationRoles.AssignItems(new Collection<ApplicationRoles> { new ApplicationRoles { ApplicationId = "1", ApplicationRoleId = "2", Description = "Test", Name = "Test" } });
         this.authorizationManager.Setup(mock => mock.RetrieveUserAuthorizationFeaturesAsync(It.IsNotNull<string>(), It.IsNotNull<string>())).Returns(Task.FromResult(applicationRoles));
         validateGuestResult = await this.loginController.ValidateGuest(objLoginPresenter) as JsonResult;
         Assert.IsTrue((bool)validateGuestResult.Data);
     }
     finally
     {
         this.Dispose();
     }
 }
        /// <summary>
        /// Indexes this instance.
        /// </summary>
        /// <returns>The view</returns>
        public ActionResult Index()
        {
            var loginPresenter = new LoginPresenter();
            loginPresenter.IsRememberMe = true;
            string userName = GetCookie(UserNameCookieKey);
            string password = GetCookie(PasswordCookieKey);
            if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password))
            {
                loginPresenter.UserName = userName;
                loginPresenter.Password = password;
            }

            BaseController.GetAboutUsInformation(loginPresenter);
            return this.View(loginPresenter);
        }
        public async Task<ActionResult> ValidateGuest(LoginPresenter logOnPresenter)
        {
            if (logOnPresenter != null)
            {
                var userName = Encoding.UTF8.GetString(Convert.FromBase64String(logOnPresenter.UserName));
                var password = Encoding.UTF8.GetString(Convert.FromBase64String(logOnPresenter.Password));

                var userAccount = new UserAccount { UserId = userName, Password = password };
                var userAccountData = await this.authenticationManager.AuthenticateUserAsync(userAccount);

                if (userAccountData != null)
                {
                    int n;
                    var userData = new User();
                    var userDataTask = this.authenticationManager.RetrieveAuthenticateUserPersonalDetails(userAccountData);
                    var masterDataTask = this.RetrieveMasterData();
                    var applicationFeaturesResult = await this.authorizationManager.RetrieveUserAuthorizationFeaturesAsync(ApplicationSettings.GangwayApplicationId, userAccountData.UserUId);

                    if (applicationFeaturesResult.Items.Count > 0)
                    {
                        SessionData.Instance.AssignApplicationFeatures(applicationFeaturesResult);
                    }
                    else
                    {
                        logOnPresenter.ShowErrorMessage = true;
                        return this.Json(false);
                    }

                    if (logOnPresenter.IsRememberMe)
                    {
                        this.SaveUserInformation(userName, password);
                    }

                    if (int.TryParse(userName, out n))
                    {
                        userData = await userDataTask;
                        SessionData.Instance.User = userData;
                    }
                    else
                    {
                        SessionData.Instance.User = userData;
                        SessionData.Instance.User.LastName = userName;
                    }
                    
                    SessionData.Instance.IsUserAuthorized = true;
                    SessionData.Instance.MasterData = await masterDataTask;
                    return this.Json(true);
                }

                logOnPresenter.ShowErrorMessage = true;
            }

            return this.Json(false);
        }
Example #41
0
    void Start()
    {
        presenter = new LoginPresenter(this);
        presenter.ViewStart();
	}
Example #42
0
        protected override void Before_each_spec()
        {
            _presenter = Create<LoginPresenter>();
             _view = Mock<ILoginView>();
             _presenter.View = _view;

             SetupResult.For(_view.Username).Return("dave");
             SetupResult.For(_view.Password).Return("test123");
             SetupResult
            .For(Get<IAuthenticationService>().Authenticate("dave", "test123"))
            .Return(false);

             var mockContainer = Mock<IWindsorContainer>();
             Locator.Initialize(mockContainer);
             SetupResult.For(mockContainer.Resolve<IWorkItemDispatcher>()).Return(new SynchronousDispatcher());
        }
 public LoginForm(LoginModel model)
 {
     InitializeComponent();
     _presenter = new LoginPresenter(this, model);
 }
        public static ActionResult ValidateAccountErrorDetails(LoginPresenter presenter)
        {
            if (presenter != null)
            {
                ValidateAccountDetails(presenter);
            }

            return new JsonResult { Data = presenter, MaxJsonLength = int.MaxValue };
        }
        private static void ValidateAccountDetails(LoginPresenter presenter)
        {
            if (string.IsNullOrWhiteSpace(presenter.UserName))
            {
                presenter.ValidationErrors.Add(Resource.UserName, UserNameValidationConstant);
            }

            if (string.IsNullOrWhiteSpace(presenter.Password))
            {
                presenter.ValidationErrors.Add(Resource.Password, PasswordValidationConstant);
            }
        }
 public void SetUp()
 {
     _view = MockRepository.GenerateMock<ILoginView>();
     _loginService = MockRepository.GenerateMock<ILoginService>();
     _presenter = new LoginPresenter(_view,_loginService);
 }