Use a Rails console
If you know the username, user ID, or email address, you can use the Rails console to reset their password:
- Open a Rails console. gitlab-rails console
- Find the user:
- By username:
-
- user = User.find_by_username 'joe'
-
- By user ID:
-
- user = User.find(123)
-
- By email address:
-
- user = User.find_by(email: 'joe@example.com')
3. Reset the password by setting a value for user.password and user.password_confirmation. For example, to set a new random password:
- new_password = ::User.random_password
- duser.password = new_password
- user.password_confirmation = new_password
- To set a specific value for the new password:
-
new_password = 'examplepassword'
user.password = new_password
user.password_confirmation = new_password
- Optional. Notify the user that an administrator changed their password:user.send_only_admin_changed_your_password_notification!
- Save the changes:
- user.save!
- Exit the console:
- exit