【问题标题】:Parse open source server reset password error解析开源服务器重置密码错误
【发布时间】:2016-07-24 18:17:03
【问题描述】:

我更新了解析服务器以在 AWS 上运行,当我点击重置密码但登录有效时出现此错误。我不确定为什么这部分代码有错误,而不是其他登录和注册。 Error Domain=Parse Code=1 "{"code":1,"message":"Internal server error."}" UserInfo={error={"code":1,"message":"Internal server error."}, NSLocalizedDescription={"code":1,"message":"Internal server error."}, code=1} 这是我必须重置的代码。

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{

  switch (alertView.alertViewStyle)
  {
    case UIAlertViewStylePlainTextInput:
    {
    UITextField *textField = [alertView textFieldAtIndex:0];
    NSLog(@"Plain text input: %@",textField.text);
    NSString *original = textField.text;
    NSString *lowercase = [original lowercaseString];

    NSLog(@"lowercase == %@",lowercase);
      // [PFUser requestPasswordResetForEmailInBackground:@"connorsapps@yahoo.com"];

    [PFUser requestPasswordResetForEmailInBackground:lowercase block:^(BOOL succeeded, NSError * _Nullable error) {
      NSLog(@"error == %@",error);
      if(error){
        [[[UIAlertView alloc] initWithTitle:@"Password Reset Error"
                                    message:@"There was a Error reseting your email."
                                   delegate:nil
                          cancelButtonTitle:@"ok"
                          otherButtonTitles:nil] show];

      } else if (!error){
        [[[UIAlertView alloc] initWithTitle:@"Password Reset"
                                    message:@"An email containing information on how to reset your password has been sent to your email."
                                   delegate:nil
                          cancelButtonTitle:@"ok"
                          otherButtonTitles:nil] show];
      }

    }];




    }
    break;

    case UIAlertViewStyleSecureTextInput:
    {
    UITextField *textField = [alertView textFieldAtIndex:0];
    NSLog(@"Secure text input: %@",textField.text);
    }
    break;

    case UIAlertViewStyleLoginAndPasswordInput:
    {
    UITextField *loginField = [alertView textFieldAtIndex:0];
    NSLog(@"Login input: %@",loginField.text);

    UITextField *passwordField = [alertView textFieldAtIndex:1];
    NSLog(@"Password input: %@",passwordField.text);
    }
    break;

    default:
    break;
  }
}

【问题讨论】:

    标签: ios objective-c amazon-web-services parse-server


    【解决方案1】:

    您是否设置了电子邮件适配器?

    看看:https://github.com/ParsePlatform/parse-server

    电子邮件验证和密码重置

    验证用户电子邮件地址并通过电子邮件启用密码重置需要电子邮件适配器。作为 parse-server 包的一部分,我们提供了一个适配器,用于通过 Mailgun 发送电子邮件。要使用它,请注册 Mailgun,并将其添加到您的初始化代码中:

    var server = ParseServer({
      ...otherOptions,
      // Enable email verification
      verifyUserEmails: true,
      // The public URL of your app.
      // This will appear in the link that is used to verify email addresses and reset passwords.
      // Set the mount path as it is in serverURL
      publicServerURL: 'https://example.com/parse',
      // Your apps name. This will appear in the subject and body of the emails that are sent.
      appName: 'Parse App',
      // The email adapter
      emailAdapter: {
        module: 'parse-server-simple-mailgun-adapter',
        options: {
          // The address that your emails come from
          fromAddress: 'parse@example.com',
          // Your domain from mailgun.com
          domain: 'example.com',
          // Your API key from mailgun.com
          apiKey: 'key-mykey',
        }
      }
    });
    

    您还可以使用社区提供的其他电子邮件适配器,例如 parse-server-sendgrid-adapter 或 parse-server-mandrill-adapter。

    将此添加到解析服务器的实例化中,如果您从 git 下载解析服务器,它最初将如下所示。

    var api = new ParseServer({
      serverURL: process.env.SERVER_URL,
      databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
      cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
      appId: process.env.APP_ID || 'myAppId',
      masterKey: process.env.MASTER_KEY || '' //Add your master key here. Keep it secret!
    });
    

    所以将第一个代码 sn -p 附加到上述示例的底部。

    var api = new ParseServer({
        serverURL: process.env.SERVER_URL,
        databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
        cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
        appId: process.env.APP_ID || 'myAppId',
        masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
        verifyUserEmails: true,
        publicServerURL: 'https://example.com/parse',
        // Your apps name. This will appear in the subject and body of the emails that are sent.
        appName: 'Parse App',
        // The email adapter
        emailAdapter: {
            module: 'parse-server-simple-mailgun-adapter',
            options: {
            // The address that your emails come from
            fromAddress: 'parse@example.com',
            // Your domain from mailgun.com
            domain: 'example.com',
            // Your API key from mailgun.com
            apiKey: 'key-mykey',
            }
        }
    });
    

    【讨论】:

    • 谢谢,我一定会试试这个我不知道这是电子邮件适配器的作用
    • @Conner :为您编辑了原始答案。
    • 我想知道publicServerURL: 'https://example.com/parse' 是什么意思——这个页面需要一些代码才能工作吗?
    • @cardigan 你想把那行变成一个变量,比如:publicServerURL: process.env.SERVER_URL || 'localhost:1337/parse'。因此,在 Heroku 中,您可以设置设置 -> 配置变量 -> 将“publicServerURL”添加到您想要的任何内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多