Skip to content

Commit e7275ba

Browse files
committed
Merge pull request strongloop#113 from strongloop/newRelease_683
Use Auto-generated email
2 parents 399da70 + 5a8d314 commit e7275ba

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

README.md

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

33
**NOTE: This module supersedes [loopback-passport](https://www.npmjs.org/package/loopback-passport). Please update your package.json accordingly.**
44

5-
The module provides integration between [LoopBack](http://loopback.io) and
5+
The module provides integration between [LoopBack](http://loopback.io) and
66
[Passport](http://passportjs.org) to support third-party login and account
77
linking for LoopBack applications.
88

@@ -12,35 +12,17 @@ linking for LoopBack applications.
1212
1313
## All local accounts requires verification
1414

15-
In order to let third party accounts to login with an email of `[email protected]` example `123456@loopback.twitter.com`
15+
### All third party accounts will login with an email of `[email protected]` example `123456@loopback.facebook.com`
1616

17-
In `./lib/models/user-identity.js`, replace:
18-
19-
```
20-
var email = profile.emails && profile.emails[0] && profile.emails[0].value;
21-
if (!email && !options.emailOptional) {
22-
// Fake an e-mail
23-
email = (profile.username || profile.id) + '@loopback.' +
24-
(profile.provider || provider) + '.com';
25-
}
26-
```
27-
28-
with
29-
30-
```
31-
var email = (profile.username || profile.id) + '@loopback.' +
32-
(profile.provider || provider) + '.com';
33-
```
34-
35-
which will allow the user to link the social media accounts that they want as well as the users could sign up with the same email account that is used for facebook/twitter/google/local if they wish to keep them separate.
17+
which will allow the user to link the social media accounts that they want as well as the users could sign up with the same email account that is used for facebook/twitter/google/local if they wish to keep them separate.
3618

3719
If more info is required from the Facebook profile such as email, it could still be obtained. In `node_modules\passport-facebook\lib\strategy.js`, replace:
3820

3921
```
4022
this._profileURL = options.profileURL || 'https://graph.facebook.com/me';
4123
```
4224

43-
with
25+
with
4426

4527
```
4628
this._profileURL = options.profileURL ||

lib/models/user-identity.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@
4444

4545
function profileToUser(provider, profile, options) {
4646
// Let's create a user for that
47-
var email = profile.emails && profile.emails[0] && profile.emails[0].value;
48-
if (!email && !options.emailOptional) {
49-
// Fake an e-mail
50-
email = (profile.username || profile.id) + '@loopback.' +
47+
var email = (profile.username || profile.id) + '@loopback.' +
5148
(profile.provider || provider) + '.com';
52-
}
5349
var username = provider + '.' + (profile.username || profile.id);
5450
var password = utils.generateKey('password');
5551
var userObj = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"security"
1010
],
1111
"homepage": "https://github.com/strongloop/loopback-component-passport",
12-
"version": "1.6.0",
12+
"version": "2.0.0",
1313
"engines": {
1414
"node": ">=0.10.0"
1515
},

test/model.user-identity.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('UserIdentity', function () {
1414
var ds = loopback.createDataSource({
1515
connector: 'memory'
1616
});
17-
17+
1818
UserIdentity.attachTo(ds);
1919
User.attachTo(ds);
2020
UserIdentity.belongsTo(User);
@@ -30,7 +30,7 @@ describe('UserIdentity', function () {
3030
function (err, user, identity, token) {
3131
assert(!err, 'No error should be reported');
3232
assert.equal(user.username, 'facebook.xyz');
33-
assert.equal(user.email, 'foo@bar.com');
33+
assert.equal(user.email, '[email protected].com');
3434

3535
assert.equal(identity.externalId, 'f123');
3636
assert.equal(identity.provider, 'facebook');
@@ -44,7 +44,7 @@ describe('UserIdentity', function () {
4444
identity.user(function (err, user) {
4545
assert(!err, 'No error should be reported');
4646
assert.equal(user.username, 'facebook.xyz');
47-
assert.equal(user.email, 'foo@bar.com');
47+
assert.equal(user.email, '[email protected].com');
4848
done();
4949
});
5050
});
@@ -104,8 +104,8 @@ describe('UserIdentity', function () {
104104
], id: 'f789', username: 'ttt'
105105
}, {accessToken: 'at3', refreshToken: 'rt3'}, function (err, user, identity, token) {
106106
assert(!err, 'No error should be reported');
107-
assert.equal(user.username, 'facebook.789');
108-
assert.equal(user.email, '789@facebook.com');
107+
assert.equal(user.username, 'facebook.ttt');
108+
assert.equal(user.email, 'ttt@loopback.facebook.com');
109109

110110
assert.equal(identity.externalId, 'f789');
111111
assert.equal(identity.provider, 'facebook');
@@ -118,8 +118,8 @@ describe('UserIdentity', function () {
118118
// Follow the belongsTo relation
119119
identity.user(function (err, user) {
120120
assert(!err, 'No error should be reported');
121-
assert.equal(user.username, 'facebook.789');
122-
assert.equal(user.email, '789@facebook.com');
121+
assert.equal(user.username, 'facebook.ttt');
122+
assert.equal(user.email, 'ttt@loopback.facebook.com');
123123
done();
124124
});
125125
});

0 commit comments

Comments
 (0)