SHARE
TWEET

Untitled

a guest Jun 19th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global class RegHandler_SF_Identity1 implements Auth.RegistrationHandler{
  2.    
  3.     // Create simple non-community user
  4.     global User createUser(Id portalId, Auth.UserData data){
  5.        
  6.       String u_domain='@demo.com';
  7.         String u_local='en_US';
  8.         String u_encKey='UTF-8';
  9.         String u_TZ='Europe/Paris';
  10.        
  11.         User u = new User();
  12.         Profile p = [SELECT Id FROM profile WHERE name='Standard User'];
  13.         u.username = data.firstname.deleteWhitespace() + u_domain;
  14.         u.email = data.email;
  15.         u.lastName = data.lastName;
  16.         u.firstName = data.firstName;
  17.         String alias = data.username;
  18.         if(alias.length() > 8) alias = alias.substring(0, 8);
  19.         u.alias = alias;
  20.         u.languagelocalekey = u_local;
  21.         u.localesidkey = u_local;
  22.         u.emailEncodingKey = u_encKey;
  23.         u.timeZoneSidKey = u_TZ;
  24.         u.profileId = p.Id;
  25.         return u;
  26. }
  27.     global void updateUser(Id userId, Id portalId, Auth.UserData data){
  28.         User u = new User(id=userId);
  29.         u.email = data.email;
  30.         u.lastName = data.lastName;
  31.         u.firstName = data.firstName;
  32.         update(u);
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top