android - 在Android中使用parse SDK更改parse用户的密码

标签 android parse-platform passwords forgot-password

我正在开发 Android 应用程序并使用 parse.com 作为后端存储。但我在更改密码时陷入困境。我可以使用 parse.com sdk 将重置密码邮件发送到特定电子邮件。但我也想使用应用程序更改密码,而无需使用旧密码登录在此处输入代码

发送邮件的功能:-

public void resetPassword() {

    CustomProgressDialog.show(LoginActivity.this, "", getResources()
                              .getString(R.string.please_wait));

    ParseUser.requestPasswordResetInBackground("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfabbaacab9fb8b2beb6b3f1bcb0b2" rel="noreferrer noopener nofollow">[email protected]</a>",
        new RequestPasswordResetCallback() {
            public void done(ParseException e) {
                CustomProgressDialog.dismissMe();

                if (e == null) {
                    // An email was successfully sent with reset
                    // instructions.
                    Toast.makeText(getApplicationContext(), getResources().getString(R.string.reset_password_sent), Toast.LENGTH_LONG).show();
                } else {
                    // Something went wrong. Look at the ParseException
                    // to see what's up.
                    Toast.makeText(getApplicationContext(), getResources().getString(R.string.reset_password_fail), Toast.LENGTH_LONG).show();
                }
            }
        }
    );
}

还可以通过在 AndroidManifest.xml 中声明权限来从邮件启动应用程序。

最佳答案

您可以使用下一个方法 ParseUser.setPassword() .

接下来的想法是,如果用户已登录,则无需检查旧密码,因为它已由 Parse.com 输入并应用。因此,您将有 2 个字段新密码确认新密码。用户输入它们,应用程序在服务器上更改它。

ParseUser parseUser = ParseUser.getCurrentUser();
parseUser.setPassword(password);
parseUser.saveInBackground(new SaveCallback() {
    @Override
    public void done(ParseException e) {
        if (null == e) {
            // report about success
        } else {
            // report about error 
        }
    }
});

关于android - 在Android中使用parse SDK更改parse用户的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27657563/

相关文章:

ios - 使用 Swift 查询进行解析

swift - 在 Swift 中解析查询 - 似乎无法将查询从最新到最旧排序

Java 验证密码

linux - 参数没有传递好

android onclick 被错误的类捕获

android - 抽屉布局打开时主要布局内容仍然可见

swift - 如何使用 Swift 将多个字段保存到 Parse 中的一行或 objectId 中?

php - 有没有办法在 PHP 5.2 中使用 bcrypt "hashing"?

android - 如何将 "Flutter for Web"转换为 "Flutter for Mobile"?

android - 在 fragment 导航组件之间传递数据的更好方法?