Search code examples
iosobjective-camazon-web-servicesparse-server

Parse open source server reset password error


I updated the parse server to run on AWS and I get this error when I hit the reset password but the login works. I am not sure why this part of the code is having a error and not the other login and sign up. 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}enter image description hereenter image description here This is the code I have to reset it.

- (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;
  }
}

Solution

  • Did you set up the email adapter?

    Take a look at : https://github.com/ParsePlatform/parse-server

    Email verification and password reset

    Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the parse-server package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:

    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',
        }
      }
    });
    

    You can also use other email adapters contributed by the community such as parse-server-sendgrid-adapter or parse-server-mandrill-adapter.

    Add this to the instantiation of the parse server, if you download the parse-server from git it will originally look like below.

    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!
    });
    

    So append the first code snippet to the bottom of the above sample.

    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',
            }
        }
    });