Skip to content

Commit be5db96

Browse files
author
Bowden
committed
remove facebook stuff
1 parent 40bdb4e commit be5db96

File tree

13 files changed

+4
-263
lines changed

13 files changed

+4
-263
lines changed

.env.example

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
MONGODB_URI=mongodb://localhost:27017
22
MONGOLAB_URI=mongodb://localhost:27017
33

4-
SESSION_SECRET=ashdfjhasdlkjfhalksdjhflak
5-
6-
FACEBOOK_ID=754220301289665
7-
FACEBOOK_SECRET=41860e58c256a3d7ad8267d3c1939a4a
4+
SESSION_SECRET=ashdfjhasdlkjfhalksdjhflak

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,14 @@ In that file you'll find two sections:
383383
| dotenv | Loads environment variables from .env file. |
384384
| errorhandler | Express 4 middleware. |
385385
| express | Node.js web framework. |
386-
| express-flash | Provides flash messages for Express. |
386+
| express-flash | Provides flash messages for Express. |
387387
| express-session | Express 4 middleware. |
388388
| express-validator | Easy form validation for Express. |
389-
| fbgraph | Facebook Graph API library. |
390389
| lusca | CSRF middleware. |
391390
| mongoose | MongoDB ODM. |
392391
| morgan | Express 4 middleware. |
393392
| nodemailer | Node.js library for sending emails. |
394393
| passport | Simple and elegant authentication library for node.js |
395-
| passport-facebook | Sign-in with Facebook plugin. |
396394
| passport-local | Sign-in with Username and Password plugin. |
397395
| pug (jade) | Template engine for Express. |
398396
| request | Simplified HTTP request library. |

package-lock.json

Lines changed: 0 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@
5353
"express-flash": "0.0.2",
5454
"express-session": "^1.15.6",
5555
"express-validator": "^4.2.1",
56-
"fbgraph": "^1.4.1",
5756
"lodash": "^4.17.4",
5857
"lusca": "^1.5.2",
5958
"mongoose": "^4.13.7",
6059
"morgan": "^1.9.0",
6160
"nodemailer": "^2.7.2",
6261
"passport": "^0.4.0",
63-
"passport-facebook": "^2.1.1",
6462
"passport-local": "^1.0.0",
6563
"pug": "^2.0.0-rc.4",
6664
"request": "^2.83.0"
@@ -85,7 +83,6 @@
8583
"@types/node": "^7.0.12",
8684
"@types/nodemailer": "^1.3.32",
8785
"@types/passport": "^0.3.3",
88-
"@types/passport-facebook": "^2.1.3",
8986
"@types/request": "^2.0.7",
9087
"@types/supertest": "^2.0.0",
9188
"concurrently": "^3.4.0",

src/app.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ app.get("/account/unlink/:provider", passportConfig.isAuthenticated, userControl
109109
* API examples routes.
110110
*/
111111
app.get("/api", apiController.getApi);
112-
app.get("/api/facebook", passportConfig.isAuthenticated, passportConfig.isAuthorized, apiController.getFacebook);
113112

114-
/**
115-
* OAuth authentication routes. (Sign in)
116-
*/
117-
app.get("/auth/facebook", passport.authenticate("facebook", { scope: ["email", "public_profile"] }));
118-
app.get("/auth/facebook/callback", passport.authenticate("facebook", { failureRedirect: "/login" }), (req, res) => {
119-
res.redirect(req.session.returnTo || "/");
120-
});
121113

122114
module.exports = app;

src/config/passport.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import * as passport from "passport";
22
import * as request from "request";
33
import * as passportLocal from "passport-local";
4-
import * as passportFacebook from "passport-facebook";
54
import * as _ from "lodash";
65

76
// import { User, UserType } from '../models/User';
87
import { default as User } from "../models/User";
98
import { Request, Response, NextFunction } from "express";
109

1110
const LocalStrategy = passportLocal.Strategy;
12-
const FacebookStrategy = passportFacebook.Strategy;
1311

1412
passport.serializeUser<any, any>((user, done) => {
1513
done(undefined, user.id);
@@ -57,67 +55,6 @@ passport.use(new LocalStrategy({ usernameField: "email" }, (email, password, don
5755
* - Else create a new account.
5856
*/
5957

60-
61-
/**
62-
* Sign in with Facebook.
63-
*/
64-
passport.use(new FacebookStrategy({
65-
clientID: process.env.FACEBOOK_ID,
66-
clientSecret: process.env.FACEBOOK_SECRET,
67-
callbackURL: "/auth/facebook/callback",
68-
profileFields: ["name", "email", "link", "locale", "timezone"],
69-
passReqToCallback: true
70-
}, (req: any, accessToken, refreshToken, profile, done) => {
71-
if (req.user) {
72-
User.findOne({ facebook: profile.id }, (err, existingUser) => {
73-
if (err) { return done(err); }
74-
if (existingUser) {
75-
req.flash("errors", { msg: "There is already a Facebook account that belongs to you. Sign in with that account or delete it, then link it with your current account." });
76-
done(err);
77-
} else {
78-
User.findById(req.user.id, (err, user: any) => {
79-
if (err) { return done(err); }
80-
user.facebook = profile.id;
81-
user.tokens.push({ kind: "facebook", accessToken });
82-
user.profile.name = user.profile.name || `${profile.name.givenName} ${profile.name.familyName}`;
83-
user.profile.gender = user.profile.gender || profile._json.gender;
84-
user.profile.picture = user.profile.picture || `https://graph.facebook.com/${profile.id}/picture?type=large`;
85-
user.save((err: Error) => {
86-
req.flash("info", { msg: "Facebook account has been linked." });
87-
done(err, user);
88-
});
89-
});
90-
}
91-
});
92-
} else {
93-
User.findOne({ facebook: profile.id }, (err, existingUser) => {
94-
if (err) { return done(err); }
95-
if (existingUser) {
96-
return done(undefined, existingUser);
97-
}
98-
User.findOne({ email: profile._json.email }, (err, existingEmailUser) => {
99-
if (err) { return done(err); }
100-
if (existingEmailUser) {
101-
req.flash("errors", { msg: "There is already an account using this email address. Sign in to that account and link it with Facebook manually from Account Settings." });
102-
done(err);
103-
} else {
104-
const user: any = new User();
105-
user.email = profile._json.email;
106-
user.facebook = profile.id;
107-
user.tokens.push({ kind: "facebook", accessToken });
108-
user.profile.name = `${profile.name.givenName} ${profile.name.familyName}`;
109-
user.profile.gender = profile._json.gender;
110-
user.profile.picture = `https://graph.facebook.com/${profile.id}/picture?type=large`;
111-
user.profile.location = (profile._json.location) ? profile._json.location.name : "";
112-
user.save((err: Error) => {
113-
done(err, user);
114-
});
115-
}
116-
});
117-
});
118-
}
119-
}));
120-
12158
/**
12259
* Login Required middleware.
12360
*/

src/controllers/api.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as async from "async";
44
import * as request from "request";
5-
import * as graph from "fbgraph";
65
import { Response, Request, NextFunction } from "express";
76

87

@@ -16,18 +15,3 @@ export let getApi = (req: Request, res: Response) => {
1615
});
1716
};
1817

19-
/**
20-
* GET /api/facebook
21-
* Facebook API example.
22-
*/
23-
export let getFacebook = (req: Request, res: Response, next: NextFunction) => {
24-
const token = req.user.tokens.find((token: any) => token.kind === "facebook");
25-
graph.setAccessToken(token.accessToken);
26-
graph.get(`${req.user.facebook}?fields=id,name,email,first_name,last_name,gender,link,locale,timezone`, (err: Error, results: graph.FacebookUser) => {
27-
if (err) { return next(err); }
28-
res.render("api/facebook", {
29-
title: "Facebook API",
30-
profile: results
31-
});
32-
});
33-
};

src/models/User.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export type UserModel = mongoose.Document & {
88
passwordResetToken: string,
99
passwordResetExpires: Date,
1010

11-
facebook: string,
1211
tokens: AuthToken[],
1312

1413
profile: {
@@ -34,9 +33,6 @@ const userSchema = new mongoose.Schema({
3433
passwordResetToken: String,
3534
passwordResetExpires: Date,
3635

37-
facebook: String,
38-
twitter: String,
39-
google: String,
4036
tokens: Array,
4137

4238
profile: {

src/types/fbgraph.d.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

views/account/login.pug

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,3 @@ block content
1919
i.fa.fa-user
2020
| Login
2121
a.btn.btn-link(href='/forgot') Forgot your password?
22-
.form-group
23-
.col-sm-offset-3.col-sm-7
24-
hr
25-
.form-group
26-
.col-sm-offset-3.col-sm-7
27-
a.btn.btn-block.btn-facebook.btn-social(href='/auth/facebook')
28-
i.fa.fa-facebook
29-
| Sign in with Facebook

0 commit comments

Comments
 (0)