10 Answers, 1 is accepted
Hi Marcel,
I assume you are calling the function users.resetPassword(). Please notice that the function is taking an object as a parameter so the supplied userName should be an object and not a string. Probably this is causing the "invalid request body" error whic is returned by the server when malformed request parameters are sent.
Let me know if the error persists.
Regards,
Martin
Telerik

this is how I set up my
service.js - resetPassword: function (loginData) {
return el.Users.resetPassword(
loginData.username)
.then(function (data) {
return data;
},
function(error){
return error;
});
},
this is how i set it up in
controller.js - // Perform the reset password action when the user press forgot password
$scope.openForgotpasswd = function () {
User.resetPassword($scope.loginData).then(function (data) {
if (data.result) {
//send password
$scope.loginData.username;
$scope.openForgotpasswd();
$state.go("/loginmain");
$scope.loginmodal.hide();
} else {
$ionicPopup.alert({
title: data.message,
template: 'Please try again!'
});
}
});
};
Hi Marcel,
Thank you for getting back to me.
Instead of a string you should construct and pass an object to the Users.resetPassword() function like this:
resetPassword:
function
(loginData) {
return
el.Users.resetPassword({
"Username"
: loginData.username // object instead of string
})
.then(
function
(data) {
return
data;
},
function
(error) {
return
error;
});
}
Regards,
Martin
Telerik


there are hundreds of emails coming to me with the email and username ive provided myself with on the app.
Also when a user register the ionicpopup display the username is already taken and pops up twice after click ok the first time.
Could it be how the code i have is structured thats causing the problem?
Hi Marcel,
1. About the multiple emails sent with resetPassword() - this behavior is really strange. Each call of the resetPassword() function should send one request to the server and subsequently for each request for password reset one email is sent. Therefore the multiple emails received indicate that the function has been called multiple times.
I have checked our server and indeed there are more than 2000 requests in a few minutes time period with resetPassword. Still I could not replicate this behavior.
Please check on your side if the function is not being called multiple times or the button is not tapped multiple times.
You may also describe the sequence of events that lead to this outcome and attach a sample that replicates the issue here. Also, specify if the app is tested in the simulator, device, etc.
2. About "when a user register the ionicpopup display the username is already taken and pops up twice" - please check whether you are not calling the register function twice - the first time it will register the user, the second time the server will return an error "A user with the same username already exists." (check also in the data browser for the Users content type whether the user is created).
Looking forward for you answer.Regards,
Martin
Telerik

hey Martin,
Service.js is set up to how you referenced it
this is how i set it up in
controller.js - // Perform the reset password action when the user press forgot password
$scope.openForgotpasswd = function () {
User.resetPassword($scope.loginData).then(function (data) {
if (data.result) {
//send password
$scope.loginData.username;
$scope.openForgotpasswd();
$state.go("/loginmain");
$scope.loginmodal.hide();
} else {
$ionicPopup.alert({
title: data.message,
template: 'Please try again!'
});
}
});
};
it doesn't look like I'm calling the function twice.
W


Yes I actually did call it twice I believe in the service.js and the controller.js
user.resetpassword($scope.loginData).then function (data) shouldn't be called since I already did it in service.js right?
i was was testing it on a device and stimulator
Hi Marcel,
The provided resetPassword functions look OK. I was referring to the register function being called twice. You are not calling the resetPassword function twice too (based on the code you have provided).
For the resetPassword.
Could you please add console.log() to both functions so that you can track in the console how many times the functions are being called like this:
In services.js:
resetPassword:
function
(loginData) {
return
el.Users.resetPassword({
"Username"
: loginData.username
// object instead of string
})
.then(
function
(data) {
console.log(
'services.js -> successCallBack resetPassword'
);
return
data;
},
function
(error) {
console.log(
'services.js -> errorCallBack resetPassword'
);
return
error;
});
}
and in controller.js:
$scope.openForgotpasswd =
function
() {
console.log(
'controller.js -> calling resetPassword'
);
User.resetPassword($scope.loginData).then(
function
(data) {
if
(data.result) {
//send password
$state.go(
"loginmain"
);
$scope.loginmodal.hide();
}
else
{
$ionicPopup.alert({
title: data.message,
template:
'Please try again!'
});
}
});
};
})
When you click on the "Reset Password!" button each function in services.js and controller.js should be called only once.
Regards,Martin
Telerik