private static void SetCommenterValuesFromOpenIdResponse(IAuthenticationResponse response, Commenter commenter)
        {
            var claimsResponse = response.GetExtension<ClaimsResponse>();
            if (claimsResponse != null)
            {
                if (string.IsNullOrWhiteSpace(commenter.Name) && string.IsNullOrWhiteSpace(claimsResponse.Nickname) == false)
                    commenter.Name = claimsResponse.Nickname;
                else if (string.IsNullOrWhiteSpace(commenter.Name) && string.IsNullOrWhiteSpace(claimsResponse.FullName) == false)
                    commenter.Name = claimsResponse.FullName;
                if (string.IsNullOrWhiteSpace(commenter.Email) && string.IsNullOrWhiteSpace(claimsResponse.Email) == false)
                    commenter.Email = claimsResponse.Email;
            }
            var fetchResponse = response.GetExtension<FetchResponse>();
            if (fetchResponse != null) // let us try from the attributes
            {
                if (string.IsNullOrWhiteSpace(commenter.Email))
                    commenter.Email = fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Email);
                if (string.IsNullOrWhiteSpace(commenter.Name))
                {
                    commenter.Name = fetchResponse.GetAttributeValue(WellKnownAttributes.Name.FullName) ??
                                     fetchResponse.GetAttributeValue(WellKnownAttributes.Name.First) + " " +
                                     fetchResponse.GetAttributeValue(WellKnownAttributes.Name.Last);
                }

                if (string.IsNullOrWhiteSpace(commenter.Url))
                {
                    commenter.Url = fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Web.Blog) ??
                                fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Web.Homepage);
                }
            }
        }
示例#2
0
		private void SetCommenter(Commenter commenter, PostComments.Comment comment)
		{
			if (requestValues.IsAuthenticated)
				return;

			commentInput.MapPropertiesToInstance(commenter);
			commenter.IsTrustedCommenter = comment.IsSpam == false;

			if (comment.IsSpam)
				commenter.NumberOfSpamComments++;

			DocumentSession.Store(commenter);
			comment.CommenterId = commenter.Id;
		}
示例#3
0
		private static void SetCommenterValuesFromResponse(ExternalLoginInfo response, Commenter commenter)
		{
			var claims = response.ExternalIdentity;

			var emailClaim = claims.FindFirst(ClaimTypes.Email);
			var nameClaim = claims.FindFirst(ClaimTypes.Name);
			var urlClaim = claims.FindFirst("urn:google:profile");

			if (string.IsNullOrWhiteSpace(commenter.Email) && emailClaim != null && string.IsNullOrWhiteSpace(emailClaim.Value) == false)
				commenter.Email = emailClaim.Value;

			if (string.IsNullOrWhiteSpace(commenter.Name) && nameClaim != null && string.IsNullOrWhiteSpace(nameClaim.Value) == false)
				commenter.Name = nameClaim.Value;

			if (string.IsNullOrWhiteSpace(commenter.Url) && urlClaim != null && string.IsNullOrWhiteSpace(urlClaim.Value) == false)
				commenter.Url = urlClaim.Value;
		}
        private void ValidateCaptcha(CommentInput input, Commenter commenter)
        {
            if (Request.IsAuthenticated ||
                (commenter != null && commenter.IsTrustedCommenter == true))
                return;

            if (RecaptchaValidatorWrapper.Validate(ControllerContext.HttpContext))
                return;

            ModelState.AddModelError("CaptchaNotValid",
                                     "You did not type the verification word correctly. Please try again.");
        }
 private void SetCommenterCookie(Commenter commenter)
 {
     var cookie = new HttpCookie(CommenterCookieName, commenter.Key.ToString())
     {Expires = DateTime.Now.AddYears(1)};
     Response.Cookies.Add(cookie);
 }
示例#6
0
        private void SetCommenter(Commenter commenter, bool isSpamComment)
        {
            if (_requestValues.IsAuthenticated)
                return;

            _commentInput.MapPropertiesToInstance(commenter);
            commenter.IsTrustedCommenter = isSpamComment == false;

            if (isSpamComment)
                commenter.NumberOfSpamComments++;

            DocumentSession.Store(commenter);
        }