Skip to content

remove assign authResponse in FB.init #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/FacebookUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @flow-weak
*/
/* global FB */
import parseDate from './parseDate';
import ParseUser from './ParseUser';

let initialized = false;
Expand Down Expand Up @@ -42,24 +41,12 @@ const provider = {

restoreAuthentication(authData) {
if (authData) {
const expiration = parseDate(authData.expiration_date);
const expiresIn = expiration ?
(expiration.getTime() - new Date().getTime()) / 1000 :
0;

const authResponse = {
userID: authData.id,
accessToken: authData.access_token,
expiresIn: expiresIn
};
const newOptions = {};
if (initOptions) {
for (const key in initOptions) {
newOptions[key] = initOptions[key];
}
}
newOptions.authResponse = authResponse;
Copy link

@schurch schurch Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @durunvo. I am also seeing this issue. In Facebook's docs I can't see what passing this to FB.init would have been for, but maybe someone who knows more about this can explain why.

If you do remove this, perhaps there is no need for the whole authResponse object on line 50 and line 72 could be changed to existingResponse.userID !== authData.id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FB.init require just 4 keys

{
  appId      : '{your-app-id}',
  status     : true,
  xfbml      : true,
  version    : 'v2.7' // or v2.6, v2.5, v2.4, v2.3
}

So yeah, I also think that it is not needed. But I want some explanation first just to make sure that this is a right thing to do.

But anyway I will push another commit according to your suggestion.


// Suppress checks for login status from the browser.
newOptions.status = false;

Expand All @@ -69,7 +56,7 @@ const provider = {
// from a Parse User that logged in with username/password.
const existingResponse = FB.getAuthResponse();
if (existingResponse &&
existingResponse.userID !== authResponse.userID) {
existingResponse.userID !== authData.id) {
FB.logout();
}

Expand Down