This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4244 from withspectrum/fix-cookie-setting-with-em…
…ail-changes Update the user cookie when confirming an email
- Loading branch information
Showing
2 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
// @flow | ||
import type { GraphQLContext } from '../../'; | ||
import { getUserById } from 'shared/db/queries/user'; | ||
|
||
export default (_: any, __: any, { user }: GraphQLContext) => | ||
user ? (user.bannedAt ? null : user) : null; | ||
export default async (_: any, __: any, { user }: GraphQLContext) => { | ||
if (!user || !user.id) return null; | ||
const dbUser = await getUserById(user.id); | ||
if (!dbUser || dbUser.bannedAt) return null; | ||
return dbUser; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,8 +190,19 @@ emailRouter.get('/validate', (req, res) => { | |
const rootRedirect = IS_PROD | ||
? `https://spectrum.chat` | ||
: `http://localhost:3000`; | ||
if (!user.username) return res.redirect(rootRedirect); | ||
return res.redirect(`${rootRedirect}/users/${user.username}/settings`); | ||
|
||
req.login(user, err => { | ||
if (err) { | ||
return res | ||
.status(400) | ||
.send( | ||
'We ran into an issue validating this email address. You can re-enter your email address in your community settings to resend a confirmation email, or get in touch with us at [email protected].' | ||
); | ||
} | ||
|
||
if (!user.username) return res.redirect(rootRedirect); | ||
return res.redirect(`${rootRedirect}/users/${user.username}/settings`); | ||
}); | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
|