Created
September 5, 2014 12:19
-
-
Save karanrajs/39cb4bd216baf2b33a72 to your computer and use it in GitHub Desktop.
Authentication Registration Handler class for the LinkedIn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class LinkedInRegHandler implements Auth.RegistrationHandler{ | |
//This method is called when the user log-in using social single sign-on credentials. | |
//This method will return the user details, either you can create new user | |
//or return the existing user if the match is found | |
global User createUser(Id portalId, Auth.UserData data){ | |
if(data.email.contains('@gmail.com')){ | |
User u = [Select id,email,isActive from user where email =: data.email and isActive = true Limit 1]; | |
return u; | |
} | |
return null; | |
} | |
//This method is called, if the user logged in before with the authorization provider and then logs in again. | |
global void updateUser(Id userId, Id portalId, Auth.UserData data){ | |
User u = new User(id=userId); | |
u.email = data.email; | |
u.lastName = data.lastName; | |
u.firstName = data.firstName; | |
update(u); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment