-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix some issues * Add note at sign up * rename useUser to useCurrentUser * Move sendVerificationEmail * eslint * Move settings page * add fields * Change profile link in layout * add _id field * Add user page * add an ugly default profile picture * Add babel-eslint * Move from profile to user/[userId] * update roadmap * Fix
- Loading branch information
Showing
15 changed files
with
116 additions
and
74 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 |
---|---|---|
|
@@ -2,5 +2,5 @@ MONGODB_URI=mongodb+srv://testuser:[email protected]/next | |
CLOUDINARY_URL=cloudinary://741947492169653:vkyuRmZ3EbSULnkfXJdtSqwhURw@dbplcha6k | ||
DB_NAME=nextjsmongodbapp | ||
SENDGRID_API_KEY=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 | ||
EMAIL_FROM=averyniceguy@nextjs-mongodb-app.hoangvvo.now.sh | ||
WEB_URI=http://localhost:3000 | ||
EMAIL_FROM=[email protected] | ||
WEB_URI=https://nextjs-mongodb.now.sh |
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
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
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
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,11 +1,10 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
// take only needed user fields to avoid sensitive ones (such as password) | ||
export function extractUser(req) { | ||
if (!req.user) return null; | ||
const { | ||
name, email, bio, profilePicture, emailVerified, | ||
_id, name, email, bio, profilePicture, emailVerified, | ||
} = req.user; | ||
return { | ||
name, email, bio, profilePicture, emailVerified, | ||
_id, name, email, bio, profilePicture, emailVerified, | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ObjectId } from 'mongodb'; | ||
|
||
export async function getUser(req, userId) { | ||
const user = await req.db.collection('users').findOne({ | ||
_id: ObjectId(userId), | ||
}); | ||
if (!user) return null; | ||
const { | ||
_id, name, email, bio, profilePicture, emailVerified, | ||
} = user; | ||
const isAuth = _id.toString() === req.user?._id.toString(); | ||
return { | ||
_id: _id.toString(), | ||
name, | ||
email: isAuth ? email : null, | ||
bio, | ||
profilePicture: profilePicture || "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-user'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E", | ||
emailVerified: isAuth ? emailVerified : null, | ||
}; | ||
} |
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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"CLOUDINARY_URL": "cloudinary://741947492169653:vkyuRmZ3EbSULnkfXJdtSqwhURw@dbplcha6k", | ||
"DB_NAME": "nextjsmongodbapp", | ||
"SENDGRID_API_KEY": "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", | ||
"EMAIL_FROM": "averyniceguy@nextjs-mongodb-app.hoangvvo.now.sh", | ||
"EMAIL_FROM": "[email protected]", | ||
"WEB_URI": "https://nextjs-mongodb.now.sh", | ||
"USING_SECRETS": "Consider using Zeit Now Secrets instead." | ||
} | ||
|
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
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
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
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
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
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
Oops, something went wrong.
10d7fcd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: