add salt in user password to make more scure?

For now, using the feature: rails g authenticationin rails 8

if we create two users with the same one password, then password_digest is same too. I suppose should add salt(which generate random by bcrypt) to make password more scure.

I think we can learn from here

Have you included the bcrypt gem? It should be generating a salt each time and storing that in the field. See this StackOverflow answer for how that works.

yes, bcrypt already salt the password by default.

At the beginning, I habitually think that there must br a independent field of salt in table of user. later I found that both password hash and password salt already saved in just one field which is password_digest.

and I found the entire process is:

  1. find the user by email_address
  2. extract the salt by the user.password_digest.salt
  3. calculate digest of the salt and params[:password]
  4. compare the digest and password_digest in db

Any way, thank you so much on this