iOS - 触发来自 Drupal 的密码恢复电子邮件

标签 ios objective-c drupal

在我的 iOS 应用中,我需要我的用户能够恢复/重置他们的密码。我正在使用 Drupal iOS SDK 来管理用户登录。一切正常,但是我想弄清楚如何将用户的电子邮件地址发布到服务端点以触发 drupal 密码恢复电子邮件? 例如 用户将电子邮件输入到 UITextField 中,然后点击提交按钮。但是,似乎没有任何相关文档?

代码如下 - 我只是不确定应该在 sendButton 中放入什么方法? DIOS用户? DIOSSession?

DIOSUser.m

 + (void)userSendPasswordRecoveryEmailWithEmailAddress: (NSString*)email

                                              success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
                                              failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {

   NSString *path = [NSString stringWithFormat:@"user/request_new_password/%@", email];
     NSLog(@"This is the input email %@", email);

    [[DIOSSession sharedSession] sendRequestWithPath:path method:@"POST" params:nil success:success failure:failure];
}

ViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];

    self.forgotField.returnKeyType = UIReturnKeyDone;
    [self.forgotField setDelegate:self];

    // Do any additional setup after loading the view from its nib.

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
    [self.view addGestureRecognizer:tap];
}

- (IBAction)return:(id)sender {

     [self dismissViewControllerAnimated:YES completion:nil];

}
- (IBAction)sendButton:(id)sender {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Retrieving Password"
                                                    message:@"We're helping you retrieve your password! Please check your email in a few minutes for a rescue link."
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];

}

错误日志:

2017-07-12 22:29:34.264669-0700 myApp[4523:1331335] 
----- DIOS Failure -----
Status code: 404
URL: http://url.com/endpoint01/user/request_new_password/me@email.com
----- Response ----- 

----- Error ----- 
Request failed: not found (404)

最佳答案

您应该简单地执行以下操作,假设 forgotField 将 emailID 作为输入并且您有适当的验证来检查有效的电子邮件。

- (IBAction)sendButton:(id)sender {

        [DIOSUser userSendPasswordRecoveryEmailWithEmailAddress:self.forgotField.text 
success:^(AFHTTPRequestOperation *operation, id responseObject) failure:^( AFHTTPRequestOperation *operation , NSError *error )){

         if(!error){
                  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Retrieving Password"
                                                        message:@"We're helping you retrieve your password! Please check your email in a few minutes for a rescue link."
                                                       delegate:self
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
               [alert show];
         }

    }];

 }

查找文档 here

干杯。

关于iOS - 触发来自 Drupal 的密码恢复电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42288049/

相关文章:

ios - 以编程方式创建不同屏幕尺寸下的对象

ios - 是否可以在 .IPA 中提供用户文件?

c - 编程简单的音调发生器,在两个立体声中各播放一个音调

drupal ctools - 如何在模态中显示 View

ios - 我使 Messenger 应用程序基于 APNS,但是如果客户端的通知被触发,则客户端不会收到 APNS 发送的其他客户端的消息

ios - 如何在 UIAlertView 中快速添加 UITableView

ios - mapView viewForOverlay 从未调用过

objective-c - 如何在 iOS 上注入(inject)用户脚本?

drupal - 显示区 block 中的节点信息

sql - Drupal 节点表和 SQL 性能问题