Skip to content

Commit

Permalink
Feature(bug-fix): share an article
Browse files Browse the repository at this point in the history
- will allow a given user to share an article

[Delivers #165525952]
  • Loading branch information
Jaman-dedy committed Apr 29, 2019
1 parent c191885 commit bdab32b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,19 @@ class UserController {
*/
async twitterLogin(req, res) {
const twitterUser = {
username: req.user.username
username: req.user.username,
isActivated: true
};
const result = await User.findOrCreate({
where: {
username: twitterUser.username
},
defaults: twitterUser
});
const { generate } = generateToken(twitterUser);
const payload = {
id: result[0].id
};
const { generate } = generateToken(payload);
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'production') {
return res.status(200).json({ status: 200, Welcome: twitterUser.username, token: generate });
} return result;
Expand Down
1 change: 1 addition & 0 deletions helpers/sendEmail/mailer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-named-as-default */
import nodemailer from 'nodemailer';
// eslint-disable-next-line import/named
import { email } from '../../config/config';
Expand Down
3 changes: 2 additions & 1 deletion middlewares/passport-facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const fbStrategy = (passport) => {
(accessToken, refreshToken, profile, done) => {
const info = {
email: profile._json.email,
username: profile._json.name
username: profile._json.name,
isActivated: true
}; User.findOrCreate({ where: { email: info.email }, defaults: info })
.then(([users, created]) => {
if (!users) {
Expand Down
3 changes: 2 additions & 1 deletion middlewares/passport-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const google = (passport) => {
} else {
const newUser = await User.create({
username: profile.emails[0].value,
email: profile.emails[0].value
email: profile.emails[0].value,
isActivated: true
});
done(null, newUser);
}
Expand Down
2 changes: 1 addition & 1 deletion testingdata/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"password": "1Kig1L@20"
},
"googleValidToken": {
"access_token": "ya29.Glz3BipVnZQGnzVLJ8MoXgqUs7Ft46ccMLxg6KGM0siyCofF8gHhrdjIfUYf7er2KvaAkIe7u4dly0VylxQB98rI7NKrBkESwKKncvcp2ky646F4KU9zQsvQOS01Aw"
"access_token": "ya29.Glv6BvVUc7NwVD3-anM4i47hPQiwrZsDeRcW3qrC3URTOT9NFTJj4ljOGRA-dR7jkOb8mepHyPHTgVKZUB057dZyU2vfXAe4kAgAeTjE7hvU0KeHROmfhQciIShZ"
},
"googleInvalidToken": {
"access_token": "ya29.Glv1Bvx5U-OTtL7Qxym4ugGyyRsxhEPoKe_Uz5cKKF_mLuGzrxHywvzLx_kgWKVfHZTKL2eg0K5oJ7RVKXwqDSG5-f5PUlo0iFz5jISJrVWsc5Ls7crApI-Uagjy"
Expand Down

0 comments on commit bdab32b

Please sign in to comment.