Ejemplo n.º 1
0
        public static void Login(UserLoginDto dto)
        {
            EnvironmentServices.SetEnvironment(dto.Environment);

            var criteria = new LoginCriteria
                               {
                                   UserName = dto.UserName,
                                   Password = dto.Password
                               };
            GenFormPrincipal.Login(criteria);
        }
Ejemplo n.º 2
0
        public static void Login(UserLoginDto dto)
        {
            EnvironmentServices.SetEnvironment(dto.Environment);

            var criteria = new LoginCriteria
            {
                UserName = dto.UserName,
                Password = dto.Password
            };

            GenFormPrincipal.Login(criteria);
        }
Ejemplo n.º 3
0
        public void Init()
        {
            _principal = Isolate.Fake.Instance<GenFormPrincipal>();
            _identity = Isolate.Fake.Instance<IGenFormIdentity>();
            Isolate.WhenCalled(() => _principal.Identity).WillReturn(_identity);

            Isolate.WhenCalled(() => GenFormPrincipal.GetPrincipal()).WillReturn(_principal);
            Isolate.WhenCalled(() => GenFormPrincipal.Login(_criteria)).IgnoreCall();

            Isolate.WhenCalled(() => EnvironmentServices.SetEnvironment(string.Empty)).IgnoreCall();

            _dto = GetAdminUserDto();
        }
Ejemplo n.º 4
0
        public ActionResult Login(UserLoginDto dto)
        {
            var success = !string.IsNullOrEmpty(GetEnvironment(dto));

            if (success)
            {
                SessionStateManager.InitializeDatabase(HttpContext.Session);
                LoginServices.Login(dto);
                success = LoginServices.IsLoggedIn(dto.UserName);

                if (success) SetLoginCookie(dto.UserName);
            } else
            {
                return this.Direct(new {success = false, message = NoEnvironmentMessage});
            }

            return this.Direct(new { success });
        }
Ejemplo n.º 5
0
 private void IsolateUserHasPasswordMethod()
 {
     _dto = GetAdminUserDto();
     var user = Isolate.Fake.Instance<IUser>();
     var password = _dto.Password;
     var userName = _dto.UserName;
     Isolate.WhenCalled(() => user.Password).WillReturn(password);
     Isolate.WhenCalled(() => UserServices.GetUserByName(userName)).WillReturn(user);
 }
Ejemplo n.º 6
0
 private static UserLoginDto GetAdminUserDto()
 {
     var dto = new UserLoginDto
                   {
                       UserName = "******",
                       Password = "******",
                       Environment = "TestGenForm"
                   };
     return dto;
 }
Ejemplo n.º 7
0
        public void MyTestInitialize()
        {
            _sessionState = Isolate.Fake.Instance<HttpSessionStateBase>();
            ObjectFactory.Configure(x => x.For<HttpSessionStateBase>().Use(_sessionState));
            _controller = ObjectFactory.GetInstance<LoginController>();

            Isolate.WhenCalled(() => EnvironmentServices.SetEnvironment("Test")).IgnoreCall();
            Isolate.WhenCalled(() => SessionStateManager.InitializeDatabase(_sessionState)).IgnoreCall();

            _user = new UserLoginDto
            {
                UserName = "******",
                Password = "******",
                Environment = Testgenform
            };
            Isolate.WhenCalled(() => LoginServices.Login(_user)).IgnoreCall();

            _response = Isolate.Fake.Instance<HttpResponseBase>();
            Isolate.WhenCalled(() =>_controller.Response).WillReturn(_response);

            _context = Isolate.Fake.Instance<HttpContextBase>();
            Isolate.WhenCalled(() => _controller.HttpContext).WillReturn(_context);
            Isolate.WhenCalled(() => _context.Session).WillReturn(_sessionState);
        }
Ejemplo n.º 8
0
        public ActionResult Login(UserLoginDto login)
        {
            var success = login.UserName == "Admin" &&
                          login.Password == "Admin" &&
                          !string.IsNullOrWhiteSpace(login.Environment);

            return this.Direct(new { success });
        }
Ejemplo n.º 9
0
 public static bool UserHasPassword(UserLoginDto userLoginDto)
 {
     return UserServices.GetUserByName(userLoginDto.UserName).Password == userLoginDto.Password;
 }
Ejemplo n.º 10
0
 public static void ChangePassword(UserLoginDto loginCriteria, string newPassword)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 11
0
        private string GetEnvironment(UserLoginDto dto)
        {
            if (!string.IsNullOrEmpty(dto.Environment)) SetEnvironment(dto.Environment);

            if (HttpContext.Session != null) return (string)HttpContext.Session[EnvironmentSetting];
            return string.Empty;
        }
Ejemplo n.º 12
0
 public static bool UserHasPassword(UserLoginDto userLoginDto)
 {
     return(UserServices.GetUserByName(userLoginDto.UserName).Password == userLoginDto.Password);
 }
Ejemplo n.º 13
0
 public static void ChangePassword(UserLoginDto loginCriteria, string newPassword)
 {
     throw new System.NotImplementedException();
 }