I use a privately hosting Gitlab's instance for a bazillion projects; and have a lot of users from around the world. Unfortunately, I have ran into a long standing bug that has never been fixed in many years. It only crops up occasionally now, but it is still a major pain for everyone involved. Many, many reports and many issues in the gitlabs issue database on this issue.
Basically, the end user never sees a "verify this email" email. And without that email; they can not login. Catch-22. In addition the "Confirm" button in the administrator account also fails to work in this situation, so neither the user nor the admin can do anything to fix it. Which then basically means I have a dead account that no one can do anything with. Until today.
These notes are so that I can easily fix it in the future.
First thing you do is go to the https://yourinstance/users/confirmation/new
and create a new verification email. This way the token you will get later is now valid (as tokens expire after a number of hours).
Next thing is login to the Docker instance; if you aren't running docker; then don't worry about this step:
docker exec -it gitlab bash
Then once inside the docker bash shell; you launch the gitlab's interactive shell -- technically you can just the gitlab-rails runner "command; command; command"
but the docker instance I run doesn't seem to have it present -- so we will launch the full gitlab rails console.
bundle exec rails console -e production
Once in this the rails console; we search for the user:
u = User.find_by_username('USERNAME')
(or u = User.find_by_any_email("emailaddress")
)
Once we have the u
variable; we can do a huge number of items on it; but what we really need to do is output the current confirmation token.
u.confirmation_token
And it will print a token that looks like this: "s2vzxVeWYhkzzDsBN8fC"
Type, exit, to exit the gitlab console. Then exit again to exit the docker instance. Go to your browser; and then use a modified version of this url:
https://yourinstance/users/confirmation?confirmation_token=<strong>s2vzxVeWYhkzzDsBN8fC</strong>
And let your browser go to it; and if you did everything correctly; you should see gitlab say it verified your email address and that you can now login.
Please note their are a lot of features/functions/data off the user "u" variable (over 3000); however, after spending over an hour trying confirmation, verification and other related features -- everything "looked" correct on the user record; but in the web admin page still showed the account was unverified. I just realized their might be some sort of user save record which then would have persisted my changes; but I didn't think about it until I was writing this blog.
However, since I could not get any of the other u.* functions to fix the record, I finally figured that the simplest way to fix this was just to have gitlab run its OWN verification code and so all I need to do is provide the token it generated myself to its verification page to make gitlab believe the end user got the email and now verified it.