When I try to login through Email authentication give error :-
Error : Passwordless login is supported only for members logging in to an Experience Cloud site.
Code:=
public with sharing class
#Trailhead Challenges #Salesforce Developer #Service Cloud #Experience Cloud #MFA - Getting Started
public with sharing class CRMLoginController {
@AuraEnabled
public static String callCommunityLogin(String email) {
try{
String response;
List<User> listUser = [SELECT Id from User WHERE Username=: email];
if(listUser != null && !listUser.isEmpty()){
String verificationId = System.UserManagement.initPasswordlessLogin(listUser[0].Id, Auth.VerificationMethod.EMAIL);
response = verificationId;
System.debug('response'+response);
}
else{
response = 'Account does not exist.';
}
return response;
}
catch(Exception e){
if(e.getMessage() == 'This user doesn\'t have access to this verification method.'){
System.debug(e.getMessage());
return e.getMessage();
}
else{
return 'Unexpected error occured.';
}
}
}
}