+ Start a Discussion
Mahesh RaghuramanMahesh Raghuraman 

Verify Member Identities for Community Self-Registration

I would like to verify community user using email address to confirm their identity using initRegisterVerificationMethod / verifyRegisterVerificationMethod. The below code when executed from Developer Console gives "Failed to get network info." error:

String userId = UserInfo.getUserId();
User u = [Select email, MobilePhone, Id from User Where Id=:userId];
//String mPh = getFormattedSms(u.MobilePhone); //Not sure why type cast issue (String) from the type anon is generated.
String exceptionText = System.UserManagement.initRegisterVerificationMethod(Auth.VerificationMethod.SMS);
System.Debug(exceptionText); //Same network error
exceptionText = System.UserManagement.initRegisterVerificationMethod(Auth.VerificationMethod.EMAIL);
System.Debug(exceptionText); //Same network error

Please let me know how to resolve this issue. Also how does iniRVM knows which mobile/email id to consider? Thanks, Mahesh

Reference-1: https://releasenotes.docs.salesforce.com/en-us/spring19/release-notes/rn_identity_login_custom_verify_pages.htm
Ref-2: https://developer.salesforce.com/docs/atlas.en-us.externalidentityImplGuide.meta/externalidentityImplGuide/external_identity_passwordless_custom_verification.htm
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Mahesh

This might me due to the following reasons : 

The method returns an error message if the phone number is already registered, the user is not external, or if the context is not a community.

Check the code in community context.