public bool Authenticate(string username, string password)
        {
            _userContext = _clientDataAccess.LogIn(username, ClassLib.DataStructures.HashClass.CreateFirstHash(password, username));

            if (_userContext != null)
            {
                const int timeout = 60;
                var       ticket  = new FormsAuthenticationTicket(
                    1,
                    username,
                    DateTime.Now,
                    DateTime.Now.AddMinutes(timeout),
                    true,
                    _userContext.Id.ToString()
                    );
                var encrypted = FormsAuthentication.Encrypt(ticket);
                var cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);

                HttpContext.Current.Response.Cookies.Add(cookie);

                _authenticationCookie = HttpContext.Current.Request.Cookies.Get(FormsAuthentication.FormsCookieName);

                return(true);
            }

            return(false);
        }
        public void ClientLogInTest()
        {
            if (clientContext1 == null)
            {
                AddNewClientTest();
            }

            var context = clientDataAccess.LogIn(ClientLogin1, HashClass.CreateFirstHash(ClientPassword1, ClientLogin1));

            Assert.IsNotNull(context);
            Assert.AreEqual(context.Login, ClientLogin1);
            Assert.AreEqual(context.Role, UserRole.Client);
        }
示例#3
0
 public void Login(string login, string password)
 {
     _userContext = _clientDataAccess.LogIn(login, HashClass.CreateFirstHash(password, login));
 }