Skip to content

Commit

Permalink
async-labs#173 mui, passport upgrade (/logout route)
Browse files Browse the repository at this point in the history
  • Loading branch information
tima101 committed Jun 20, 2022
1 parent 3c2cec3 commit ed5716e
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 216 deletions.
4 changes: 2 additions & 2 deletions saas/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"marked": "^4.0.16",
"mongoose": "^6.3.5",
"node-fetch": "^2.6.1",
"passport": "^0.4.1",
"passport": "^0.6.0",
"passport-google-oauth": "^2.0.0",
"passwordless": "^1.1.3",
"passwordless-tokenstore": "^0.0.10",
Expand All @@ -57,7 +57,7 @@
"@types/mongoose": "^5.5.43",
"@types/node": "^12.12.2",
"@types/node-fetch": "^1.6.9",
"@types/passport": "^0.4.5",
"@types/passport": "^1.0.8",
"@types/socket.io": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
Expand Down
16 changes: 8 additions & 8 deletions saas/api/server/api/team-leader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ router.use((req, res, next) => {
next();
});

router.post('/teams/add', async (req, res, next) => {
router.post('/teams/add', async (req: any, res, next) => {
try {
const { name, avatarUrl } = req.body;

Expand All @@ -32,7 +32,7 @@ router.post('/teams/add', async (req, res, next) => {
}
});

router.post('/teams/update', async (req, res, next) => {
router.post('/teams/update', async (req: any, res, next) => {
try {
const { teamId, name, avatarUrl } = req.body;

Expand All @@ -52,7 +52,7 @@ router.post('/teams/update', async (req, res, next) => {
}
});

router.get('/teams/get-invitations-for-team', async (req, res, next) => {
router.get('/teams/get-invitations-for-team', async (req: any, res, next) => {
try {
const invitations = await Invitation.getTeamInvitations({
userId: req.user.id,
Expand All @@ -65,7 +65,7 @@ router.get('/teams/get-invitations-for-team', async (req, res, next) => {
}
});

router.post('/teams/invite-member', async (req, res, next) => {
router.post('/teams/invite-member', async (req: any, res, next) => {
try {
const { teamId, email } = req.body;

Expand All @@ -77,7 +77,7 @@ router.post('/teams/invite-member', async (req, res, next) => {
}
});

router.post('/teams/remove-member', async (req, res, next) => {
router.post('/teams/remove-member', async (req: any, res, next) => {
try {
const { teamId, userId } = req.body;

Expand All @@ -89,7 +89,7 @@ router.post('/teams/remove-member', async (req, res, next) => {
}
});

router.post('/stripe/fetch-checkout-session', async (req, res, next) => {
router.post('/stripe/fetch-checkout-session', async (req: any, res, next) => {
try {
const { mode, teamId } = req.body;

Expand Down Expand Up @@ -121,7 +121,7 @@ router.post('/stripe/fetch-checkout-session', async (req, res, next) => {
}
});

router.post('/cancel-subscription', async (req, res, next) => {
router.post('/cancel-subscription', async (req: any, res, next) => {
const { teamId } = req.body;

try {
Expand All @@ -136,7 +136,7 @@ router.post('/cancel-subscription', async (req, res, next) => {
}
});

router.get('/get-list-of-invoices-for-customer', async (req, res, next) => {
router.get('/get-list-of-invoices-for-customer', async (req: any, res, next) => {
try {
const { stripeListOfInvoices } = await User.getListOfInvoicesForCustomer({
userId: req.user.id,
Expand Down
24 changes: 12 additions & 12 deletions saas/api/server/api/team-member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ router.post('/aws/get-signed-request-for-upload-to-s3', async (req, res, next) =
}
});

router.post('/user/update-profile', async (req, res, next) => {
router.post('/user/update-profile', async (req: any, res, next) => {
try {
const { name, avatarUrl } = req.body;

Expand All @@ -65,7 +65,7 @@ router.post('/user/update-profile', async (req, res, next) => {
}
});

router.post('/user/toggle-theme', async (req, res, next) => {
router.post('/user/toggle-theme', async (req: any, res, next) => {
try {
const { darkTheme } = req.body;

Expand Down Expand Up @@ -130,7 +130,7 @@ async function loadTeamData(team, userId, body) {
return data;
}

router.post('/get-initial-data', async (req, res, next) => {
router.post('/get-initial-data', async (req: any, res, next) => {
try {
const teams = await Team.getAllTeamsForUser(req.user.id);

Expand Down Expand Up @@ -164,7 +164,7 @@ router.post('/get-initial-data', async (req, res, next) => {
// }
// });

router.get('/teams/get-members', async (req, res, next) => {
router.get('/teams/get-members', async (req: any, res, next) => {
try {
const users = await User.getMembersForTeam({
userId: req.user.id,
Expand All @@ -177,7 +177,7 @@ router.get('/teams/get-members', async (req, res, next) => {
}
});

router.post('/discussions/add', async (req, res, next) => {
router.post('/discussions/add', async (req: any, res, next) => {
try {
const { name, teamId, memberIds = [], socketId, notificationType } = req.body;

Expand All @@ -197,7 +197,7 @@ router.post('/discussions/add', async (req, res, next) => {
}
});

router.post('/discussions/edit', async (req, res, next) => {
router.post('/discussions/edit', async (req: any, res, next) => {
try {
const { name, id, memberIds = [], socketId, notificationType } = req.body;

Expand All @@ -217,7 +217,7 @@ router.post('/discussions/edit', async (req, res, next) => {
}
});

router.post('/discussions/delete', async (req, res, next) => {
router.post('/discussions/delete', async (req: any, res, next) => {
try {
const { id, socketId } = req.body;

Expand All @@ -231,7 +231,7 @@ router.post('/discussions/delete', async (req, res, next) => {
}
});

router.get('/discussions/list', async (req, res, next) => {
router.get('/discussions/list', async (req: any, res, next) => {
try {
const { discussions } = await Discussion.getList({
userId: req.user.id,
Expand All @@ -244,7 +244,7 @@ router.get('/discussions/list', async (req, res, next) => {
}
});

router.get('/posts/list', async (req, res, next) => {
router.get('/posts/list', async (req: any, res, next) => {
try {
const posts = await Post.getList({
userId: req.user.id,
Expand All @@ -257,7 +257,7 @@ router.get('/posts/list', async (req, res, next) => {
}
});

router.post('/posts/add', async (req, res, next) => {
router.post('/posts/add', async (req: any, res, next) => {
try {
const { content, discussionId, socketId } = req.body;

Expand All @@ -271,7 +271,7 @@ router.post('/posts/add', async (req, res, next) => {
}
});

router.post('/posts/edit', async (req, res, next) => {
router.post('/posts/edit', async (req: any, res, next) => {
try {
const { content, id, socketId } = req.body;

Expand All @@ -285,7 +285,7 @@ router.post('/posts/edit', async (req, res, next) => {
}
});

router.post('/posts/delete', async (req, res, next) => {
router.post('/posts/delete', async (req: any, res, next) => {
try {
const { id, discussionId, socketId } = req.body;

Expand Down
26 changes: 15 additions & 11 deletions saas/api/server/passwordless-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,22 @@ function setupPasswordless({ server }) {
},
);

server.get('/logout', passwordless.logout(), (req, res) => {
req.logout();
server.get('/logout', (req, res, next) => {
req.logout((err) => {
if (err) {
next(err);
}

if (req.query && req.query.invitationToken) {
res.redirect(
`${dev ? process.env.URL_APP : process.env.PRODUCTION_URL_APP}/invitation?token=${
req.query.invitationToken
}`,
);
} else {
res.redirect(`${dev ? process.env.URL_APP : process.env.PRODUCTION_URL_APP}/login`);
}
if (req.query && req.query.invitationToken) {
res.redirect(
`${dev ? process.env.URL_APP : process.env.PRODUCTION_URL_APP}/invitation?token=${
req.query.invitationToken
}`,
);
} else {
res.redirect(`${dev ? process.env.URL_APP : process.env.PRODUCTION_URL_APP}/login`);
}
});
});
}

Expand Down
45 changes: 23 additions & 22 deletions saas/api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -576,24 +576,24 @@
defer-to-connect "^1.0.1"

"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==
version "1.0.9"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2"
integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==

"@tsconfig/node12@^1.0.7":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c"
integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==
version "1.0.10"
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.10.tgz#10fecee4a3be17357ce99b370bd81874044d8dbd"
integrity sha512-N+srakvPaYMGkwjNDx3ASx65Zl3QG8dJgVtIB+YMOkucU+zctlv/hdP5250VKdDHSDoW9PFZoCqbqNcAPjCjXA==

"@tsconfig/node14@^1.0.0":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2"
integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==
version "1.0.2"
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.2.tgz#b09c08de2eb319ca2acab17a1b8028af110b24b3"
integrity sha512-YwrUA5ysDXHFYfL0Xed9x3sNS4P+aKlCOnnbqUa2E5HdQshHFleCJVrj1PlGTb4GgFUCDyte1v3JWLy2sz8Oqg==

"@tsconfig/node16@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==
version "1.0.3"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e"
integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==

"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7":
version "7.1.12"
Expand Down Expand Up @@ -807,10 +807,10 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==

"@types/passport@^0.4.5":
version "0.4.7"
resolved "https://registry.yarnpkg.com/@types/passport/-/passport-0.4.7.tgz#2b7f29bf61df91cf77023b3777e940b613d4b4d8"
integrity sha512-EePlxNYx5tf3n0yjdPXX0/zDOv0UCwjMyQo4UkWGlhHteNDItAj7TfDdLttSThVMKQz3uCW7lsGzMuml0f8g9Q==
"@types/passport@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@types/passport/-/passport-1.0.8.tgz#cc3ee653777365ac02f630c3c08fb755567b7387"
integrity sha512-Gdcvis7+7G/Mobm+25AeFi+oe5teBhHzpbCOFWeN10Bj8tnoEE1L5lkraQjzmDEKkJQuM7xSJUGIFGl/giyRfQ==
dependencies:
"@types/express" "*"

Expand Down Expand Up @@ -4668,13 +4668,14 @@ [email protected]:
resolved "https://registry.yarnpkg.com/passport-strategy/-/passport-strategy-1.0.0.tgz#b5539aa8fc225a3d1ad179476ddf236b440f52e4"
integrity sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=

passport@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/passport/-/passport-0.4.1.tgz#941446a21cb92fc688d97a0861c38ce9f738f270"
integrity sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==
passport@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/passport/-/passport-0.6.0.tgz#e869579fab465b5c0b291e841e6cc95c005fac9d"
integrity sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug==
dependencies:
passport-strategy "1.x.x"
pause "0.0.1"
utils-merge "^1.0.1"

passwordless-tokenstore@^0.0.10:
version "0.0.10"
Expand Down Expand Up @@ -4726,7 +4727,7 @@ path-type@^4.0.0:
[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/pause/-/pause-0.0.1.tgz#1d408b3fdb76923b9543d96fb4c9dfd535d9cb5d"
integrity sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=
integrity sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==

performance-now@^2.1.0:
version "2.1.0"
Expand Down Expand Up @@ -6105,7 +6106,7 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1:
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=

[email protected], [email protected]:
[email protected], [email protected], utils-merge@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
Expand Down
10 changes: 5 additions & 5 deletions saas/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"start": "node production-server/server.js"
},
"dependencies": {
"@emotion/cache": "^11.6.0",
"@emotion/react": "^11.6.0",
"@emotion/cache": "^11.9.3",
"@emotion/react": "^11.9.3",
"@emotion/server": "^11.4.0",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.2.0",
"@mui/material": "^5.2.0",
"@emotion/styled": "^11.9.3",
"@mui/icons-material": "^5.8.3",
"@mui/material": "^5.8.3",
"@stripe/stripe-js": "^1.21.1",
"express": "^4.17.1",
"he": "^1.2.0",
Expand Down
Loading

0 comments on commit ed5716e

Please sign in to comment.