Exemplo n.º 1
0
        public string GetAuthCookie(User user)
        {
            Ensure.That(() => user).IsNotNull();

            string encoded = EncodeUserIdIntoAuthCookie(user.Id);
            return encoded;
        }
Exemplo n.º 2
0
        protected internal AuthenticationResult SuccessfulAuthentication(User user, bool isNewUser = false, bool? isNewConnection = null)
        {
            string authCookie = userService.GetAuthCookie(user);
            formsAuthentication.SetAuthCookie(authCookie, true);

            return new AuthenticationResult
            {
                Status = ConnectionStatus.Authenticated,
                DisplayName = user.DisplayName,
                UserId = user.Id,
                IsNewUser = isNewUser,
                IsNewConnection = isNewConnection ?? isNewUser
            };
        }
Exemplo n.º 3
0
        public void TestInit()
        {
            // Arrange
            Mock<IUserRepository> userRepository = new Mock<IUserRepository>();
            User user = new User
            {
                Email = "test",
                Password = "******"
            };

            userRepository.Setup(x => x
                                          .GetByEmail("test"))
                .Returns(user);

            userRepository.Setup(x => x
                                          .AreMatchingPasswords(It.IsAny<string>(), It.IsAny<string>()))
                .Returns((string l, string r) => l == r);

            miniMembership = MockHelpers.FakeMiniMembership(userRepository.Object);
        }
Exemplo n.º 4
0
        public Comment Create(long postId, string message, User user, long? parentId)
        {
            Ensure.That(() => message).IsNotNull();
            Ensure.That(() => user).IsNotNull();

            if (parentId.HasValue)
            {
                // prevent nesting deeper than one level.
                Comment parent = commentRepository.GetById(parentId.Value);
                Ensure.That(() => parent == null || parent.ParentId.HasValue).IsFalseOrThrow<ArgumentOutOfRangeException>();
            }
            Comment comment = new Comment
            {
                PostId = postId,
                Message = message,
                Created = DateTime.UtcNow,
                UserId = user.Id,
                ParentId = parentId
            };
            return commentRepository.Insert(comment);
        }
Exemplo n.º 5
0
 public MiniIdentity(User user, string authenticationType)
 {
     this.user = user;
     AuthenticationType = authenticationType;
 }
Exemplo n.º 6
0
 public Post Create(Link link, string message, User user)
 {
     Post post = postRepository.Insert(link, message, user);
     return post;
 }
Exemplo n.º 7
0
 public void AddOpenIdConnection(User user, string openId)
 {
     userRepository.AddOpenIdConnection(user, openId);
 }
Exemplo n.º 8
0
 public void AddFacebookConnection(User user, string facebookId, string accessToken)
 {
     userRepository.AddFacebookConnection(user, facebookId, accessToken);
 }
Exemplo n.º 9
0
        public void SendRegistrationEmail(User user)
        {
            Ensure.That(() => user).IsNotNull();

            emailService.SendRegistrationEmail(user.Email, new RegistrationEmailModel
            {
                DisplayName = user.DisplayName
            });
        }
Exemplo n.º 10
0
 public bool IsInRoleOrHasRight(User user, string roleOrRight)
 {
     bool allowed = userRepository.IsInRoleOrHasRight(user, roleOrRight);
     return allowed;
 }