解析开源服务器重设密码错误
Parse open source server reset password error
我在 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;
}
}
您是否设置了电子邮件适配器?
看看: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',
}
}
});
我在 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;
}
}
您是否设置了电子邮件适配器?
看看: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',
}
}
});