我更新了解析服务器以在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;
}
}
答案 0 :(得分:4)
您是否设置了电子邮件适配器?
看看: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!
});
所以将第一个代码段附加到上面示例的底部。
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',
}
}
});