示例#1
0
        private IRegisteredUser UpdateMember(IRegisteredUser user, Guid verticalId, ExternalUserData userData)
        {
            if (user is Member)
            {
                // User exists, but their details may have changed.

                var member = (Member)user;
                if (member.FirstName != userData.FirstName || member.LastName != userData.LastName || member.GetBestEmailAddress().Address != userData.EmailAddress)
                {
                    member.FirstName      = userData.FirstName;
                    member.LastName       = userData.LastName;
                    member.EmailAddresses = new List <EmailAddress> {
                        new EmailAddress {
                            Address = userData.EmailAddress, IsVerified = true
                        }
                    };
                    _memberAccountsCommand.UpdateMember(member);
                }

                // Associate them with the vertical if needed.

                if (verticalId != user.AffiliateId)
                {
                    _memberAffiliationsCommand.SetAffiliation(user.Id, verticalId);
                }
            }

            return(user);
        }
示例#2
0
        private IRegisteredUser AuthenticateUser(Guid verticalId, ExternalUserData userData)
        {
            var result = _externalAuthenticationCommand.AuthenticateUser(new ExternalCredentials {
                ProviderId = verticalId, ExternalId = userData.ExternalId
            });

            switch (result.Status)
            {
            case AuthenticationStatus.Authenticated:
                return(UpdateMember(result.User, verticalId, userData));

            case AuthenticationStatus.Deactivated:

                // Shouldn't be deactivated so activate them now.

                _userAccountsCommand.ActivateUserAccount(result.User, result.User.Id);
                return(UpdateMember(result.User, verticalId, userData));

            case AuthenticationStatus.Failed:

                // Haven't seen this person before so create them an account.

                return(CreateMember(verticalId, userData));

            default:

                // Nothing that can be done here.

                return(null);
            }
        }
示例#3
0
        private IRegisteredUser CreateMember(Guid verticalId, ExternalUserData userData)
        {
            // User does not exist, create them now making sure they are activated.

            var member = new Member
            {
                FirstName      = userData.FirstName,
                LastName       = userData.LastName,
                EmailAddresses = new List <EmailAddress> {
                    new EmailAddress {
                        Address = userData.EmailAddress, IsVerified = true
                    }
                },
                Address = new Address {
                    Location = _locationQuery.ResolveLocation(ActivityContext.Current.Location.Country, null)
                },
                VisibilitySettings = new VisibilitySettings(),
                IsActivated        = true,
            };

            _memberAccountsCommand.CreateMember(member, new ExternalCredentials {
                ProviderId = verticalId, ExternalId = userData.ExternalId
            }, verticalId);
            return(member);
        }
 public ExternalAuthenticationInfoException(IEnumerable <string> missingFields = null, ExternalUserData receivedData = null)
     : base("External authentication yielded insufficient information to allow local login.")
 {
     ReceivedData  = receivedData;
     MissingFields = missingFields;
 }