2016-04-05 40 views
1

我更新瞭解析服務器以在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}enter image description hereenter image description here 這是我必須重置它的代碼。解析開源服務器重置密碼錯誤

- (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:@"[email protected]"]; 

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

回答

4

您是否設置了電子郵件適配器?

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

電子郵件驗證和密碼重置

驗證用戶的電子郵件地址並啓用密碼重置通過電子郵件requries電子郵件適配器。作爲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: '[email protected]', 
     // Your domain from mailgun.com 
     domain: 'example.com', 
     // Your API key from mailgun.com 
     apiKey: 'key-mykey', 
    } 
    } 
}); 

您還可以使用貢獻的社會其他電子郵件適配器,例如解析服務器,sendgrid適配器或解析服務器,山魈-適配器。

將此添加到分析服務器的實例化中,如果您從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! 
}); 

所以第一個代碼段附加到上述樣品的底部。

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: '[email protected]', 
     // Your domain from mailgun.com 
     domain: 'example.com', 
     // Your API key from mailgun.com 
     apiKey: 'key-mykey', 
     } 
    } 
}); 
+0

謝謝你,我會確保試試這個我不知道那是什麼的電子郵件適配器確實 – Connor

+0

我在哪裏把代碼? – Connor

+0

@Conner:爲您編輯原始答案。 – tanz