0

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);
},
})

1 Answer 1

0

https://success.salesforce.com/issues_view?id=a1p3A00000031PwQAI&title=unable-to-reset-the-password-using-system-resetpassword-with-aura-session

Seems to be a known issue. Check to see if your instance is still listed as one that it is not fixed for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .