Skip to content

Commit 27bfc9e

Browse files
committed
feat(social-auth): added sending name and avatar data by social authenticating to the app
1 parent 092d9e4 commit 27bfc9e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/auth/auth.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ passport.use(new GoogleStrategy({
3131
db.User.findOrCreate({ where: {email: profile.email}}).then(([user, created]) => {
3232
const body = {
3333
id: user.id,
34-
email: user.email
34+
email: user.email,
35+
name: profile.displayName,
36+
avatar: profile.picture
3537
};
3638
const token = helpers.jwtSign({user: body});
3739
return done(null, {token});
@@ -51,7 +53,8 @@ passport.use(new MicrosoftStrategy({
5153
db.User.findOrCreate({where: {email}}).then(([user, created]) => {
5254
const body = {
5355
id: user.id,
54-
email: user.email
56+
email: user.email,
57+
name: profile.displayName
5558
};
5659
const token = helpers.jwtSign({user: body});
5760
return done(null, {token});

src/routes/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ router.get('/signin/google/callback', passport.authenticate("google", {failureRe
5656
}
5757
);
5858

59-
router.get('/signin/microsoft', passport.authenticate("microsoft", {scope: ["openid", "https://graph.microsoft.com/user.read", "email"]}));
59+
router.get('/signin/microsoft', passport.authenticate("microsoft", {scope: ["https://graph.microsoft.com/user.read openid"]}));
6060

6161
router.get('/signin/microsoft/callback', passport.authenticate("microsoft", {failureRedirect: "/login", session: false}),
6262
function (req, res) {

0 commit comments

Comments
 (0)