Skip to content

Be able to reset user password #182

Closed

Description

@sibelius

can you point it out how to implement this ?

Activity

  1. Morthor commented on Sep 3, 2024

    @Morthor

    There's also no way for a user to recover their own password

  2. aldy505 commented on Sep 3, 2024

    @aldy505

    There's also no way for a user to recover their own password

    There is actually, by changing the Postgres row directly. It's just a regular password hash (I forgot whether it's bcrypt or argon2).

    I might implement a "change password" API endpoint later.

  3. Morthor commented on Sep 3, 2024

    @Morthor

    There's also no way for a user to recover their own password

    There is actually, by changing the Postgres row directly. It's just a regular password hash (I forgot whether it's bcrypt or argon2).

    I might implement a "change password" API endpoint later.

    I'm sorry, but that does not answer my comment. A user themselves cannot access the Postgres DB to recover their password.
    Does this mean that right now the only way would be for the admin to change the Postgres row to a new hashed password, tell that password to the user, and have them change after?

  4. aldy505 commented on Sep 3, 2024

    @aldy505

    There's also no way for a user to recover their own password

    There is actually, by changing the Postgres row directly. It's just a regular password hash (I forgot whether it's bcrypt or argon2).

    I might implement a "change password" API endpoint later.

    I'm sorry, but that does not answer my comment. A user themselves cannot access the Postgres DB to recover their password.

    Does this mean that right now the only way would be for the admin to change the Postgres row to a new hashed password, tell that password to the user, and have them change after?

    Sadly yes.

  5. Morthor commented on Sep 3, 2024

    @Morthor

    There's also no way for a user to recover their own password

    There is actually, by changing the Postgres row directly. It's just a regular password hash (I forgot whether it's bcrypt or argon2).

    I might implement a "change password" API endpoint later.

    I'm sorry, but that does not answer my comment. A user themselves cannot access the Postgres DB to recover their password.
    Does this mean that right now the only way would be for the admin to change the Postgres row to a new hashed password, tell that password to the user, and have them change after?

    Sadly yes.

    That does leave me very sad. I was about to expand the usage of DocMost from a small group to a few dozen users, but I can't be available to go into the docker instance running docmost, into postgres, to make this change every time someone forgets their password.
    I really enjoy the simplicity of DocMost, it's a tool with great potencial, but without the basic authentication functionality and user management, it becomes unusable for most use cases.

  6. aldy505 commented on Sep 3, 2024

    @aldy505

    There's also no way for a user to recover their own password

    There is actually, by changing the Postgres row directly. It's just a regular password hash (I forgot whether it's bcrypt or argon2).

    I might implement a "change password" API endpoint later.

    I'm sorry, but that does not answer my comment. A user themselves cannot access the Postgres DB to recover their password.

    Does this mean that right now the only way would be for the admin to change the Postgres row to a new hashed password, tell that password to the user, and have them change after?

    Sadly yes.

    That does leave me very sad. I was about to expand the usage of DocMost from a small group to a few dozen users, but I can't be available to go into the docker instance running docmost, into postgres, to make this change every time someone forgets their password.

    I really enjoy the simplicity of DocMost, it's a tool with great potencial, but without the basic authentication functionality and user management, it becomes unusable for most use cases.

    It's a bummer for me, too. Our story seems similar 😆. But hey, it's still early, there are lots of room for improvement.

  7. Philipinho commented on Sep 3, 2024

    @Philipinho
    Member

    Password reset will be available in the next release.

  8. sibelius commented on Sep 3, 2024

    @sibelius
    Author
    import { createPool, sql } from 'slonik';
    import * as bcrypt from 'bcrypt';
    
    export async function hashPassword(password: string) {
      const saltRounds = 12;
      return bcrypt.hash(password, saltRounds);
    }
    
    export const run = async (email: string, newPassword: string): Promise<any> => {
      const pool = await createPool(process.env.DOCMOST_DB_URL);
    
      const hashed = await hashPassword(newPassword);
    
      const query = sql.unsafe`
        UPDATE users
        SET password = ${hashed}
        WHERE email = ${email} and workspace_id = ${workspaceId}
      `;
    
      const result =await pool.query(query);
    };
  9. aldy505 commented on Sep 3, 2024

    @aldy505

    Password reset will be available in the next release.

    @Philipinho are you working on it yet? If you're not. I can implement that.

    Basically the flow is:

    1. Pass in the email of the user
    2. User will receive an email with a certain code, only if their account exists on docmost.
    3. User validate that code, put in a new password (with confirmation).

    2 new API endpoints

  10. aldy505 commented on Sep 3, 2024

    @aldy505

    There you go: #250

    Does anyone want to implement the frontend side? I'm not really good with React, so.. yeah. I probably can't do that.

  11. sahariardev commented on Sep 6, 2024

    @sahariardev
    Contributor

    @Philipinho and @aldy505 I want to develop the frontend

  12. sahariardev commented on Sep 7, 2024

    @sahariardev
    Contributor

    There you go: #250

    Does anyone want to implement the frontend side? I'm not really good with React, so.. yeah. I probably can't do that.

    Here is the frontend side #273

  13. ddkooker2 commented on Sep 9, 2024

    @ddkooker2

    In the mean time, does anyone have the commands/procedure to manually reset the password?

  14. aldy505 commented on Sep 9, 2024

    @aldy505

    In the mean time, does anyone have the commands/procedure to manually reset the password?

    @ddkooker2 this one #182 (comment)

  15. quaintdev commented on Sep 10, 2024

    @quaintdev

    I am locked out of my account! Any other way we can reset the password?

  16. Philipinho commented on Sep 10, 2024

    @Philipinho
    Member

    @quaintdev If you can run a small node script, see #182 (comment).

    Otherwise, you could generate a 12-round password hash of your desired password from https://bcrypt-generator.com/. Then update the password manually in the Postgres db.

    docker exec DB_CONTAINER_ID psql -U docmost -d docmost -c "UPDATE users SET password = 'PASSWORD_HASH' WHERE email = 'YOUR-EMAIL';"
  17. quaintdev commented on Sep 10, 2024

    @quaintdev

    @quaintdev If you can run a small node script, see #182 (comment).

    Otherwise, you could generate a 12-round password hash of your desired password from https://bcrypt-generator.com/. Then update the password manually in the Postgres db.

    docker exec DB_CONTAINER_ID psql -U docmost -d docmost -c "UPDATE users SET password = 'PASSWORD_HASH' WHERE email = 'YOUR-EMAIL';"

    This worked. Thanks!

  18. Philipinho commented on Sep 19, 2024

    @Philipinho
    Member

    Password reset UI.
    Thanks to contributions from @aldy505 and @sahariardev.

    Ps: It will be available in the next release.

    Screenshot 2024-09-19 at 15 52 54 Screenshot 2024-09-19 at 16 00 56
  19. heinrihs-s commented on Mar 14, 2025

    @heinrihs-s

    When updating password hashes in PostgreSQL through a container's console in Portainer, you need to handle dollar signs ($) carefully as psql may interpret them as variable substitution markers.

    psql -U docmost -d docmost -c "UPDATE users SET password = $pass$$2a$12$ZTMgX4lFWSSqKDeij4Q/W.Qb/fmzD3fAophfD8jpeWIqKlLhan02$pass$ WHERE email = '[email protected]';"
  20. pomfei commented on Oct 22, 2025

    @pomfei

    @Philipinho docker exec DB_CONTAINER_ID psql -U docmost -d docmost -c "UPDATE users SET password = 'PASSWORD_HASH' WHERE email = 'YOUR-EMAIL';"
    it doesn‘t work now,maybe the website hash is not right?

  21. southalan commented on Dec 31, 2025

    @southalan

    @pomfei

    @Philipinho docker exec DB_CONTAINER_ID psql -U docmost -d docmost -c "UPDATE users SET password = 'PASSWORD_HASH' WHERE email = 'YOUR-EMAIL';" it doesn‘t work now,maybe the website hash is not right?

    I might be a few months late, but I had a similar issue, let me give you an example:

    Password: 123456
    Hashed: $2a$12$yENzrI3ZewBAf8edKpsED.lXw3GXaC2HZL1zIJfzbizaLvV0M.O7e
    
    docker exec DB_CONTAINER_ID psql -U docmost -d docmost -c "UPDATE users SET password = '\$2a\$12\$yENzrI3ZewBAf8edKpsED.lXw3GXaC2HZL1zIJfzbizaLvV0M.O7e' WHERE email = '[email protected]';"
    

    As heinrihs-s previously mentioned, you should escape the "$" dollar sign to avoid issues.

    If done correctly, you will get a "UPDATE 1" as a result, and the "$" will not be cut/replaced within the hashed password string.

    Cheers!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions