public async Task<ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation();

            var userId = externalLoginInfo.Principal.FindFirstValue("urn:twitter:userid");
            var screenName = externalLoginInfo.Principal.FindFirstValue("urn:twitter:screenname");

            var twitterAccount = await twitterRepository.GetTwitterAccount(userId, screenName);

            if (twitterAccount != null && twitterAccount.User != null)
            {
                var twitterUser = twitterAccount.User;
                externalUserInformation.Email = twitterUser.Email;

                if (!string.IsNullOrEmpty(twitterUser.Name))
                {
                    var array = twitterUser.Name.Split(' ');
                    if (array.Length > 1)
                    {
                        externalUserInformation.FirstName = array[0];
                        externalUserInformation.LastName = array[1];
                    }
                }
            }

            return externalUserInformation;
        }
Exemple #2
0
        public Task <ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation {
                Email = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Email)
            };

            var name = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Name);

            if (string.IsNullOrEmpty(name))
            {
                return(Task.FromResult(externalUserInformation));
            }

            var array = name.Split(' ');

            if (array.Length < 2)
            {
                return(Task.FromResult(externalUserInformation));
            }

            externalUserInformation.FirstName = array[0];
            externalUserInformation.LastName  = array[1];

            return(Task.FromResult(externalUserInformation));
        }
        public async Task <ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation();

            var userId     = externalLoginInfo.Principal.FindFirstValue("urn:twitter:userid");
            var screenName = externalLoginInfo.Principal.FindFirstValue("urn:twitter:screenname");

            var twitterAccount = await twitterRepository.GetTwitterAccount(userId, screenName);

            if (twitterAccount != null && twitterAccount.User != null)
            {
                var twitterUser = twitterAccount.User;
                externalUserInformation.Email = twitterUser.Email;

                if (!string.IsNullOrEmpty(twitterUser.Name))
                {
                    var array = twitterUser.Name.Split(' ');
                    if (array.Length > 1)
                    {
                        externalUserInformation.FirstName = array[0];
                        externalUserInformation.LastName  = array[1];
                    }
                }
            }

            return(externalUserInformation);
        }
        public Task <ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation
            {
                Email     = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Email),
                FirstName = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.GivenName),
                LastName  = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Surname)
            };

            return(Task.FromResult(externalUserInformation));
        }
        public Task<ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation
            {
                Email = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Email),
                FirstName = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.GivenName),
                LastName = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Surname)
            };

            return Task.FromResult(externalUserInformation);
        }
        public async Task <ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation();

            var screenName = externalLoginInfo.Principal.FindFirstValue("urn:twitter:screenname");
            var email      = externalLoginInfo.Principal.FindFirstValue(@"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress");

            if (string.IsNullOrEmpty(email))
            {
                _logger.LogError($"Failed to retrieve user email address for user {screenName} from Twitter, this could be due to either the setup of the app (ensure the app requests email address permissions) or this user has a blank/unverified email in Twitter");
                return(externalUserInformation);
            }

            externalUserInformation.Email = email;
            return(externalUserInformation);
        }
        public Task<ExternalUserInformation> GetExternalUserInformation(ExternalLoginInfo externalLoginInfo)
        {
            var externalUserInformation = new ExternalUserInformation { Email = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Email) };

            var name = externalLoginInfo.Principal.FindFirstValue(ClaimTypes.Name);
            if (string.IsNullOrEmpty(name))
            {
                return Task.FromResult(externalUserInformation);
            }

            var array = name.Split(' ');
            if (array.Length < 2)
            {
                return Task.FromResult(externalUserInformation);
            }

            externalUserInformation.FirstName = array[0];
            externalUserInformation.LastName = array[1];

            return Task.FromResult(externalUserInformation);
        }