问题
I'm working on a Titanium based iOS application.
In which I need to implement the password reset functionality within my app.
I found this requestResetPassword
method for doing this:
Cloud.Users.requestResetPassword({
email: 'me@mycompany.com'
}, function (e) {
if (e.success) {
alert('Success: Reset Request Sent');
} else {
alert('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
From docs it says that, it'll send a reset password option to user's mail account. But I don't want that. I need to reset password within my application.
Also I can't remove the current user and create a new account for the same user with new password because there is a lot of custom data saved for each particular user. So that's not a good solution.
Also I found the update
function, but I don't know how to use it for updating the password field in cloud, because it is not a custom field.
Cloud.Users.update({
email: 'me@mycompany.com',
first_name: 'm',
last_name: 'e',
}, function (e) {
if (e.success) {
var user = e.users[0];
alert('Success:\\n' +
'id: ' + user.id + '\\n' +
'first name: ' + user.first_name + '\\n' +
'last name: ' + user.last_name);
} else {
alert('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
Is there anyway to do this from my application ? How can I update user's password field within my application ?
Referred docs:
- Titanium.Cloud.Users-module
- Titanium.Cloud.Users
Please help, thanks in advance.
回答1:
Use "update". Specify the password properties like you do in your create call:
{
password: 'cheese',
password_confirmation: 'cheese',
email: 'codfish@joe.com'
}
http://cloud.appcelerator.com/docs/api/v1/users/update
来源:https://stackoverflow.com/questions/14331696/update-password-field-from-titanium-application