My Use case is: As a CustomerCommunity user, I want to login and click on change_password link that redirects me to change_password page in AngularJs, which calles the changePassword method using javascript remoting, so that I can change my password. Issue: This method returns pageReference as null. this is my code: Visualforce Page:
<apex:page controller="CustomCommunitiesLandingController" docType="html-5.0">
<script>
function chgPwd() {
var newPassword = document.getElementById('newPwd').value;
var verifyNewPassword = document.getElementById('verPwd').value;
var oldPassword = document.getElementById('oldPwd').value;
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.CustomCommunitiesLandingController.changePassword}',newPassword,verifyNewPassword,oldPassword,
function(result, event) {
alert("result");
});
}
</script>
<div class="bootstrap" >
oldPwd <input type="text" id='oldPwd' />
newpwd<input type="text" id='newPwd' />
verpwd<input type="text" id='verPwd' />
<h1 align="center">Click The Button</h1>
<button onClick="chgPwd()" class="btn btn-lg btn-default btn-block">change password</button>
</div>
</apex:page>
Controller Method:
@remoteAction
public static String changePassword(string newPassword, string verifyNewPassword, string oldPassword){
pageReference pr;
string success;
pr = Site.changePassword(newPassword, verifyNewPassword, oldPassword);
if(pr != null){
success = 'true';
}else {
success = 'false';
}
return success;
}
Any help is greatly appreciated!
Thank you, Devayani