Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: sequelize hook for bcrypt, apply bcrypt in seeds, and bcrypt c… #21

Merged
merged 2 commits into from
May 22, 2021

Conversation

dhvasquez
Copy link
Contributor

@dhvasquez dhvasquez commented May 21, 2021

Bcrypt tutorial

What?

  • Sequelize hook for hashing with bcrypt
  • Hash password in seeds with bcrypt hashSync
  • Hash compare method in user model

Why?

  • For hashing tutorial video

How?

  • Use of sequelize hooks to implement hashing using bcrypt library

Testing?

  • No new route added, so no new test applied

Screenshots

  • No frontend change

Anything Else?

Functions used

// Hash string
bcrypt.hash(string, SALT_ROUNDS);  // returns Promise that resolves int o a hash
bcrypt.hashSync(string, SALT_ROUNDS);  // synchronous method for hashing

// Hash compare with string
bcrypt.compare(string, hash);  // returns Promise that resolves into bool

Fixed

Added await to compare promise, this change is not reflected in the video, for full change log check this Pull Request.

@dhvasquez dhvasquez requested a review from sivicencio May 21, 2021 20:42
Copy link
Contributor

@sivicencio sivicencio left a comment

Choose a reason for hiding this comment

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

Great and concise code 👍🏼

@@ -13,7 +13,7 @@ router.post('session.create', '/', async (ctx) => {
const user = await ctx.orm.user.findOne({ where: { email } });

/* TODO: replace plain-text password comparison with encrypted version */
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove this line, please? It doesn't apply to this case anymore.

Removed to do comment cause it is already done
@dhvasquez dhvasquez merged commit 350b253 into main May 22, 2021
@sivicencio sivicencio deleted the dhvasquez/feat/hash-example branch July 5, 2021 03:10
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