public IActionResult FacebookLogin(string returnUrl)
        {
            if (!_externalAuthenticationService.AuthenticationProviderIsAvailable(FacebookAuthenticationDefaults.ProviderSystemName))
            {
                throw new GrandException("Facebook authentication module cannot be loaded");
            }

            if (string.IsNullOrEmpty(_facebookExternalAuthSettings.ClientKeyIdentifier) || string.IsNullOrEmpty(_facebookExternalAuthSettings.ClientSecret))
            {
                throw new GrandException("Facebook authentication module not configured");
            }

            //configure login callback action
            var authenticationProperties = new AuthenticationProperties {
                RedirectUri = Url.Action("FacebookLoginCallback", "FacebookAuthentication", new { returnUrl = returnUrl })
            };

            return(Challenge(authenticationProperties, FacebookDefaults.AuthenticationScheme));
        }
Example #2
0
        private async Task PrepareExternalAuth(CustomerInfoModel model, GetInfo request)
        {
            model.NumberOfExternalAuthenticationProviders = _externalAuthenticationService
                                                            .LoadActiveAuthenticationProviders(request.Customer, request.Store).Count;
            foreach (var ear in await _externalAuthenticationService.GetExternalIdentifiers(request.Customer))
            {
                if (!_externalAuthenticationService.AuthenticationProviderIsAvailable(ear.ProviderSystemName))
                {
                    continue;
                }

                var authMethod = _externalAuthenticationService.LoadAuthenticationProviderBySystemName(ear.ProviderSystemName);

                model.AssociatedExternalAuthRecords.Add(new CustomerInfoModel.AssociatedExternalAuthModel {
                    Id    = ear.Id,
                    Email = ear.Email,
                    ExternalIdentifier = ear.ExternalDisplayIdentifier,
                    AuthMethodName     = authMethod.FriendlyName
                });
            }
        }