示例#1
0
        public string GetAuthCookie(User user)
        {
            Ensure.That(() => user).IsNotNull();

            string encoded = EncodeUserIdIntoAuthCookie(user.Id);
            return encoded;
        }
        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
            };
        }
示例#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);
        }
示例#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);
        }
示例#5
0
 public MiniIdentity(User user, string authenticationType)
 {
     this.user = user;
     AuthenticationType = authenticationType;
 }
示例#6
0
 public Post Create(Link link, string message, User user)
 {
     Post post = postRepository.Insert(link, message, user);
     return post;
 }
示例#7
0
 public void AddOpenIdConnection(User user, string openId)
 {
     userRepository.AddOpenIdConnection(user, openId);
 }
示例#8
0
 public void AddFacebookConnection(User user, string facebookId, string accessToken)
 {
     userRepository.AddFacebookConnection(user, facebookId, accessToken);
 }
示例#9
0
        public void SendRegistrationEmail(User user)
        {
            Ensure.That(() => user).IsNotNull();

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