Exemplo n.º 1
0
        public void GetUser_ExistingUser_ReturnCorrectUser()
        {
            Guid userId;
            var  user = new User
            {
                AccessType = AccountAccessType.Full,
                Email      = "*****@*****.**",
                Name       = "SomeUser"
            };
            var userModel = _mapper.Map <User, UserModel>(user);

            using (var dbContext = new ExpenseDbContext(Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                dbContext.Users.Add(userModel);
                dbContext.SaveChanges();
                userId = userModel.Id;
            }
            user.Id = userId;

            // Act
            var obtainedUser = _accountFacade.GetUser(user.Id);

            // Assert
            Assert.AreEqual(obtainedUser, user, "GetUser failed - users do not match.");
        }
Exemplo n.º 2
0
        public bool Login(LoginData data, out string result)
        {
            var login = _accountFacade.GetUser(data.Login);

            if (login == null)
            {
                result = Messanger.Get(EMessages.UserDoesntExist);
                return(false);
            }
            if (!login.PassHash.SequenceEqual(data.PasswordHash ?? GetSha1Hash(data.Password)))
            {
                result = Messanger.Get(EMessages.IncorrectUserPassword);
                return(false);
            }

            //запись в cookie(AuthCookie)
            //data.User = login;
            FormsAuthentication.SetAuthCookie(login.Id.ToString(), data.RememberMe);
            result = string.Empty;
            return(true);
        }