5

I installed openproject in CentOS 7 using docker. I changed the admin password and then I forgot it.

How can I reset it.?

aamadeo
  • 347
  • 4
  • 10

2 Answers2

6

For newer versions of OpenProject, Ulferts' solution seems not to work, but I was successfull using the information in this guide:

  1. Find out the container ID: docker ps.
  2. Connect to the docker container as root: docker exec -u root -it <CONTAINER ID> /bin/bash
  3. Change the users password with rails console:
    RAILS_ENV=production bundle exec rails c
    u = User.find_by_login "admin"
    u.password=u.password_confirmation='my new password'
    u.save
    
  4. (Hit Ctrl-D until you're back on your regular terminal.)
moi
  • 1,835
  • 2
  • 18
  • 25
5

If the settings permit (which is the default), the easiest solution would be to go to the login page (https://[host]/login) of the OpenProject installation (via a browser) and use the "Forgot your password?" link to have a password reset token send to the email address configured for the admin account.

If that option does not exist, you have to connect to the docker container to get a terminal window on it, e.g. by following this how-to.

Once you have a bash open, issue:

sudo openproject run rails console

which will open a rails console for you.

Once inside, issue:

# retrieve first admin account
admin = User.where(admin: true).first
# change the password
admin.password = admin.password_confirmation = "[The password you choose]"
# Save the change disregarding any errors
admin.save(validate: false)

In case you have more than one admin account on the installation, you will have to narrow down the correct one in the first step by e.g.

# print a list of all admin accounts
pp User.where(admin: true).pluck(:id, :login, :firstname, :lastname, :mail)
# Fetch admin account by id
admin = User.where(id: "[the id]")
ulferts
  • 2,187
  • 12
  • 19
  • 5
    Hello, I'm trying to use your solution but I get errors: root@ee12ce60a11b:/app# sudo openproject run rails console bash: sudo: command not found root@ee12ce60a11b:/app# openproject run rails console bash: openproject: command not found ``` – greg Nov 06 '19 at 16:08
  • I'd assume that sudo ist not installed. You might fix the problem by connecting to the docker container as root: https://stackoverflow.com/a/49529946/3206935 – ulferts Mar 04 '20 at 16:09
  • 4
    I connected as root, but: `/app# openproject run rails console` results in `bash: openproject: command not found` – moi Aug 21 '20 at 07:54
  • 1
    I used ` admin = User.where(admin: true, login: "admin" ).first ` to change the password of the specific admin. – purushothaman poovai Jun 09 '22 at 10:34