简体   繁体   English

Parse.com-使用Fb身份验证时更新PFUser的电子邮件

[英]Parse.com - Update email for PFUser while using Fb authentication

I'm receiving PFUser properly while log in or sign up through Facebook. 登录或通过Facebook注册时,我正确接收PFUser。 My permission array: 我的权限数组:

NSArray *permissionsArray = @[ @"user_about_me",@"email"];

In Parse Data browser, I can see that a user got created with some long string username and proper authData etc. But email field is still empty. 在“解析数据”浏览器中,我可以看到使用长字符串用户名和正确的authData等创建的用户。但是电子邮件字段仍然为空。

Do I need to make separate call to fill email field for the newly created PFUser ? 我是否需要单独拨打电话以填写新创建的PFUser的电子邮件字段? If Yes then what are the proper steps. 如果是,那么正确的步骤是什么。

Another question, how forgot password mechanism work for facebook authenticated user in Parse.com ? 另一个问题,在Parse.com中,Facebook身份验证用户的忘记密码机制如何工作? Do I need to fill email value first by calling graph api and then use that email address for forgot password feature ? 我是否需要先通过调用图形API来填写电子邮件值,然后使用该电子邮件地址来忘记密码功能?

You need to make a separate call to fill the email attribute. 您需要单独致电以填充电子邮件属性。 Once the user is authenticated, you can call the startForMeWithCompletionHandler: method of FBRequestConnection class to get the user info and then save it to the current user. 用户通过身份验证后,可以调用FBRequestConnection类的startForMeWithCompletionHandler:方法来获取用户信息,然后将其保存到当前用户。 Your calls should look like this: 您的通话应如下所示:

NSArray *permissionsArray = @[ @"user_about_me",@"email"];
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
    if (!error && user) {
        [FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
            if (!error) {
                [[PFUser currentUser] setObject:[result objectForKey:@"email"]
                                         forKey:@"email"];
                [[PFUser currentUser] saveInBackground];
            }
        }];
    }
}];

About the forgot password for Facebook users, it doesn't make sense since if the user forgot the password, it should change it on Facebook. 关于Facebook用户的忘记密码,这没有意义,因为如果用户忘记了密码,则应该在Facebook上更改密码。 But, if you call requestPasswordResetForEmail: method, it would send instructions for changing the password to the user since the email exists. 但是,如果您调用requestPasswordResetForEmail:方法,由于电子邮件存在,它将向用户发送更改密码的说明。 Take into account that the logInWithUsername:password: uses the attribute username to log in the user, not the email, and that value it is probably unknown for Facebook users in your app. 考虑到logInWithUsername:password:使用属性用户名而不是电子邮件登录用户,而该值对于您的应用程序中的Facebook用户来说可能是未知的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM