Skip to content
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

Add Facebook login #1366

Merged
merged 13 commits into from
Oct 13, 2020
Merged

Add Facebook login #1366

merged 13 commits into from
Oct 13, 2020

Conversation

OtterleyW
Copy link
Contributor

@OtterleyW OtterleyW commented Sep 22, 2020

Adds Facebook login to FTW

This is how the authentication flow works in general:

Screenshot 2020-10-02 at 13 40 38
Screenshot 2020-10-02 at 13 41 22

(these graphs are also in Whimsical Socia logins & SSO board https://whimsical.com/GcZr7nhZwex4WfYgAuiHFG)

Screenshot 2020-09-22 at 14 37 02

If a new user needs to be created there is a new ConfirmSignupForm on ConfirmPage to confirm the data fetched from e.g. Facebook:
Screenshot 2020-09-22 at 14 36 42

This PR can be merged after #1365 is merged to the base branch #1364

@OtterleyW OtterleyW force-pushed the add-idp-endpoints-to-server branch 2 times, most recently from 85bec53 to 5e1d608 Compare October 1, 2020 14:36
@OtterleyW OtterleyW changed the base branch from add-idp-endpoints-to-server to social-logins October 2, 2020 10:47
Comment on lines 28 to 39
res
.cookie(
'st-autherror',
{
status: err.status,
code: err.code,
message: err.message,
},
{
maxAge: 15 * 60 * 1000, // 15 minutes
}
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two new cookies st-autherror and st-auhtinfo in this flow and @Gnito mentioned that it would be good to document the cookies we use in some place. I'm not sure what would be the best place to do this? E.g. add article to Flex docs or something else

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd vote Flex Docs.

src/config.js Show resolved Hide resolved
tab,
sendVerificationEmailInProgress,
sendVerificationEmailError,
onResendVerificationEmail,
onManageDisableScrolling,
showSocialLoginsForTests,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The snapshot test for AuthenticationPage caused some issues because in the local environment facebook app id was in environment variables and in CI it was not. Because of this, the social login button was added to snapshot when running tests locally but in CI the page was expected to be rendered without the social login button.

Adding extra prop feels really hacky but I'm not sure in what another way we could ensure that the page is rendered similarly locally and in CI. Also with the prop, it was possible to test both options.

Do you have any better ideas on how to handle the snapshot test (or do we even need to keep it)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I agree, this feels a bit hacky.

Jest should automatically define NODE_ENV to be 'test'.
So, try adding the Facebook app id to .env.test (maybe as empty)

src/containers/ListingPage/ListingPage.js Outdated Show resolved Hide resolved
@OtterleyW OtterleyW requested a review from Gnito October 2, 2020 11:12
@OtterleyW OtterleyW requested a review from lyyder October 2, 2020 11:12
@lyyder lyyder temporarily deployed to sharetribe-starter-app October 5, 2020 10:54 Inactive
@rap1ds rap1ds temporarily deployed to sharetribe-starter-app October 5, 2020 12:22 Inactive
src/util/api.js Outdated Show resolved Hide resolved
src/util/api.js Outdated Show resolved Hide resolved
server/index.js Outdated Show resolved Hide resolved
) : null;

const formContent = isConfirm ? (
<div className={css.content}>
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing to consider in this kind of ternary-chain is that should one or more of these be subcomponent (inside this directory) to improve readability.

(And I'm not saying that this is necessarily hard to read, but in Github, it's a bit confusing due to partially visible content.)

server/api/auth/facebook.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Gnito Gnito left a comment

Choose a reason for hiding this comment

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

I added some comments.
I'm not sure I'm completely aware of all the aspects, but I still think we should parameterize all the possible return paths.

@OtterleyW OtterleyW temporarily deployed to sharetribe-starter-app October 6, 2020 07:44 Inactive
@lyyder lyyder temporarily deployed to sharetribe-starter-app October 6, 2020 08:59 Inactive
src/translations/en.json Outdated Show resolved Hide resolved
@OtterleyW OtterleyW merged commit f238d60 into social-logins Oct 13, 2020
@OtterleyW OtterleyW mentioned this pull request Oct 14, 2020
3 tasks
@Gnito Gnito deleted the add-facebook-login branch October 28, 2020 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants