Update password field from Titanium application

☆樱花仙子☆ 提交于 2019-12-12 01:32:41

问题


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:

  1. Titanium.Cloud.Users-module
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!