Skip to content

Conversation

@minggg012
Copy link

야호~

@Byunk Byunk changed the title pull request Min May 1, 2023
Copy link
Member

@Byunk Byunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

const salt = await bcrypt.genSalt(saltRounds);
console.log(salt);
const hashedPassword = await bcrypt.hash(password, salt);
const user: UserDocument = await User.create({ _id: new mongoose.Types.ObjectId(), username, password: hashedPassword, name, email });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_id는 따로 설정 안해주셔도 자동으로 생성됩니다!
await User.create(
{
username: username,
password: hashedPassword,
name: name,
email: email,
})

export async function loginUser(req: Request, res: Response, next: NextFunction) {
try {
const { username, password }: { username: string; password: string } = req.body;
const user: UserDocument | null = await User.findOne({ username }).exec();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await User.findOne(
{
username: username
}
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants