Exemplo n.º 1
0
        public void InsertUserTwice()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                //INIT
                var register = new UsersRepository(fixture.Setup.Context);

                //ACT / POST
                var user = new User()
                {
                    Email = "email",
                    //SecretPhrase = "sec",
                    //Password = "******"
                };

                register.Save(user);

                var newUser = new User()
                {
                    Email = "email",
                    //SecretPhrase = "sec",
                    //Password = "******"
                };

                register.Save(newUser);
            }
        }
Exemplo n.º 2
0
        private static EmailMessage CreateEmailMessageForUser(User user)
        {
            var message = String.Format(
                    "<p>Dear {0},</p>" +
                    "<p>" +
                        "Thank you very much for your registration on <a href=\"http://trackyt.net\">Trackyt.net</a>." + 
                    "</p>" +
                    "<p>" +
                        "In nearest hour we are going to apply patch that would improve security and privacy of our site." +
                        "All passwords that was previously stored open-text will be removed. We would kindly remind " +
                        "password that you used during registration." +
                    "</p>" + 
                    "<p>" +
                        "Password: {1}" +
                    "</p>" +
                    "<p>" +
                        "Please keep this email, because we will not be able to remind you password if you lost it." +
                    "</p>"
                , user.Email, user.Password);

            var email = new EmailMessage { 
                From = "*****@*****.**", 
                To = user.Email, 
                Message = message, 
                Subject = "Trackyt.net password reminder", 
                IsHtml = true };

            return email;
        }
Exemplo n.º 3
0
        public void Save(User user)
        {
            if (_failOnRegister)
                throw new Exception();

            _users.Add(user);    
        }
Exemplo n.º 4
0
        public void Save(User user)
        {
            if (user.Id == 0)
            {
                if (Users.WithEmail(user.Email) != null)
                    throw new DuplicateKeyException(user);

                _context.Users.InsertOnSubmit(user);
            }

            _context.SubmitChanges();
        }
        private User CreateUserWithTempFlag(string email, string password, bool temp)
        {
            var user = new User
            {
                Email = email,
                PasswordHash = _hash.CreateMD5Hash(password),
                ApiToken = _hash.CreateApiToken(email, password),
                Temp = temp
            };

            return user;
        }
Exemplo n.º 6
0
        public void InsertUser()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                //INIT
                var register = new UsersRepository(fixture.Setup.Context);

                //ACT
                var user = new User()
                {
                    Email = "email",
                    //SecretPhrase = "sec",
                    //Password = "******"
                };

                register.Save(user);

                //POST
                var actual = register.Users.WithEmail("email");
                Assert.That(actual, Is.Not.Null);
            }
        }
Exemplo n.º 7
0
        public void FindUserById()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                //INIT
                var register = new UsersRepository(fixture.Setup.Context);

                var user = new User()
                {
                    Email = "email",
                    //SecretPhrase = "sec",
                    //Password = "******"
                };

                register.Save(user);

                //ACT
                var foundUser = register.Users.WithId(user.Id);

                //POST
                Assert.That(foundUser, Is.Not.Null);
                Assert.That(foundUser.Id, Is.EqualTo(user.Id));
            }
        }
Exemplo n.º 8
0
 public void Delete(User user)
 {
     _context.Users.DeleteOnSubmit(user);
     _context.SubmitChanges();
 }
Exemplo n.º 9
0
 public void Delete(User user)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 partial void DeleteUser(User instance);
Exemplo n.º 11
0
 partial void UpdateUser(User instance);
Exemplo n.º 12
0
 partial void InsertUser(User instance);
Exemplo n.º 13
0
 private void SaveAndAuthenticate(string email, string password, User user)
 {
     _users.Save(user);
     Authenticate(email, password);
 }