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 }; }
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); }
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); }
public MiniIdentity(User user, string authenticationType) { this.user = user; AuthenticationType = authenticationType; }
public Post Create(Link link, string message, User user) { Post post = postRepository.Insert(link, message, user); return post; }
public void AddOpenIdConnection(User user, string openId) { userRepository.AddOpenIdConnection(user, openId); }
public void AddFacebookConnection(User user, string facebookId, string accessToken) { userRepository.AddFacebookConnection(user, facebookId, accessToken); }
public void SendRegistrationEmail(User user) { Ensure.That(() => user).IsNotNull(); emailService.SendRegistrationEmail(user.Email, new RegistrationEmailModel { DisplayName = user.DisplayName }); }
public bool IsInRoleOrHasRight(User user, string roleOrRight) { bool allowed = userRepository.IsInRoleOrHasRight(user, roleOrRight); return allowed; }