From 0cf42ef0dbe395959bfac64d3fba654c1bb49d73 Mon Sep 17 00:00:00 2001 From: Siddaiah M Date: Sat, 23 May 2020 12:31:17 +0530 Subject: [PATCH 1/2] Implemented facebook login auth feature -user can login through facebook account --- .vscode/settings.json | 7 ++- README.md | 5 ++ package.json | 1 + pages/public/login.js | 12 +++++ public/favicon-16x16.png | Bin 0 -> 561 bytes server/app.js | 2 + server/facebook.js | 99 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 public/favicon-16x16.png create mode 100644 server/facebook.js diff --git a/.vscode/settings.json b/.vscode/settings.json index cc9911388..86107086b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,8 @@ { - "window.zoomLevel": -1, - "files.autoSave": "afterDelay", + "window.zoomLevel": 1, + "files.autoSave": "off", "git.enableSmartCommit": true, - "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 3709f8ef8..212e5d3a1 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Check out projects built with the help of this open source app. Feel free to add - Get `Google_clientID` and `Google_clientSecret` by following [official OAuth tutorial](https://developers.google.com/identity/sign-in/web/sign-in#before_you_begin). Important: For Google OAuth app, callback URL is: http://localhost:8000/oauth2callback
+ Important: For Facebook OAuth app, callback URL is: http://localhost:8000/auth/facebook/callback
Important: You have to enable Google+ API in your Google Cloud Platform account. - Specify your own secret key for Express session `SESSION_SECRET`: https://github.com/expressjs/session#secret @@ -69,6 +70,10 @@ To use all features and third-party integrations (such as Stripe, Google OAuth, Google_clientID="xxxxxx" Google_clientSecret="xxxxxx" + # Used in server/facebook.js + FACEBOOK_CLIENT_ID="xxxxxxxxxx" + FACEBOOK_CLIENT_SECRET="xxxxxxxx" + # Used in server/aws.js Amazon_accessKeyId="xxxxxx" Amazon_secretAccessKey="xxxxxx" diff --git a/package.json b/package.json index 42a67be9a..76b058e39 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "next": "9.1.6", "nprogress": "0.2.0", "passport": "0.4.1", + "passport-facebook": "^3.0.0", "passport-google-oauth": "2.0.0", "prop-types": "15.7.2", "qs": "6.9.1", diff --git a/pages/public/login.js b/pages/public/login.js index 6c469a991..ca6dbabab 100644 --- a/pages/public/login.js +++ b/pages/public/login.js @@ -19,6 +19,18 @@ function Login({ router }) {

Log in

You’ll be logged in for 14 days unless you log out manually.


+