コード例 #1
0
        private bool IsCredentialsValid(string mail, string password)
        {
            var relatedUserWithWebMasterRole = Optional(_intranetUserService.GetByEmail(mail))
                                               .Filter(member => member.Role.Name == IntranetRolesEnum.WebMaster.ToString())
                                               .Bind(member => member.UmbracoId.ToOption())
                                               .Map(id => _memberService.GetById(id));

            Option <IMember> GetUserWithMatchingEmail() => Optional(_memberService.GetByEmail(mail));

            return(EnumerableExtensions
                   .Choose(relatedUserWithWebMasterRole, GetUserWithMatchingEmail)
                   .Map(user => Membership.ValidateUser(user.Username, password))
                   .IfNone(() => false));
        }