function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew FandreAndrew Fandre 

Auth. Provider continuously returning to provider

I enabled an Auth. Provider for our community to authenticate through our company OpenId server. I've got the connection working, it gets to our server, and I'm able to use it to authenticate, but when it returns to the community it just bounces back to the auth server, opening infinite new tabs.

Here's the code in the handler that I pulled from the Trailhead example that authenticates to Facebook.
global User createUser(Id portalId, Auth.UserData data){
        User u;
   
        if(!canCreateUser(data)) {
            u = null;
        } else {
            List<User> userList = [select id from User where email =: data.email];
           
            u = userList[0];
        }
        
        return u;
    }
The other method "canCreateUser" is just validating the data object values to see if they're null.

Any ideas why this is continuously requesting authorization?
 
Best Answer chosen by Andrew Fandre
Andrew FandreAndrew Fandre
Just got help from Salesforce about this issue. It turns out that the query is comparing email when it should be comparing to federationidentifier. Federationidentifier is a value I've never heard of or seen in any documentation. But once I changed the query to 
List<User> userList = [select id from User where federationidentifier =: data.email];
Authentication worked..