I'm trying to reset the password for the logged-in user and I'm getting this error
INVALID_SESSION_ID: This session is not valid for use with the API
public class apexclass1 {
@AuraEnabled
public static void resetUserPassword() {
List<User> commUserList = [SELECT Id FROM User WHERE Id = '005xx000001Sv7I' LIMIT 1];
ResetPasswordResult rpr = System.resetPassword(commUserList.Id, true);
System.debug('/// ' + rpr.getPassword());
}
}
Lightning Component
<aura:component controller="apexclass1" implements="flexipage:availableForAllPageTypes,force:appHostable">
<lightning:button label="Reset Password" onclick="{!c.reset}" />
</aura:component>
Controller:
({
reset : function(component, event, helper) {
console.log('zzz ' + 'Invoked resetUserPassword');
var action = component.get("c.resetUserPassword");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
console.log('SUCCESS');
} else if (state === "ERROR") {
console.log('ERROR');
}
});
$A.enqueueAction(action);
},
})