Skip to content

Instantly share code, notes, and snippets.

@macdja38
Created July 26, 2018 20:14
Show Gist options
  • Save macdja38/3d62d4f251bd7c46f0128bb6a9d35544 to your computer and use it in GitHub Desktop.
Save macdja38/3d62d4f251bd7c46f0128bb6a9d35544 to your computer and use it in GitHub Desktop.
Confirm gitlab email by CLI

On your gitlab server run gitlab-rails console production

Find your user via user = User.find_by(email: "[email protected]")

Optionally change the user's email with user.email = "[email protected]" Then run user.save!

Get the user's token with user.confirmation_token

https://PutYourGitlabHere/users/confirmation?confirmation_token=PutYourTokenHere

I used this to change my email on a gitlab instance without an email server.

@Schnitzel
Copy link

thank you, this saved me hours <3

@nemeth-it
Copy link

Same here. Thanks!

@nfriend
Copy link

nfriend commented Aug 24, 2020

❤️ 👍 😄

@hesstobi
Copy link

hesstobi commented Sep 1, 2020

To verify a secondary email use:

email = Email.find_by(email: "[email protected]")
email.confirm()

@gpchelkin
Copy link

gpchelkin commented Nov 2, 2020

UPD: To verify a secondary email use:

email = Email.find_by(email: "[email protected]")
email.confirmed_at = Time.zone.now
email.save!

Works on GitLab 13.3.4
Idea from https://docs.gitlab.com/ce/user/upgrade_email_bypass.html#what-do-i-do-if-i-am-an-administrator-and-i-am-locked-out

@eli-yip
Copy link

eli-yip commented Jan 21, 2024

thank you so much!!!

@skwerlman
Copy link

skwerlman commented Dec 10, 2024

A cleaner way to verify (as of 17.6.1, probably earlier too) is this:

user = User.find_by(email: "[email protected]")
user.confirm()

This works for secondary emails too:

email = Email.find_by(email: "[email protected]")
email.confirm()

@ScarlettSamantha
Copy link

ScarlettSamantha commented Jan 20, 2025

For me it could not find it by email. You are also able to search by eg: user = User.find_by(id: 1) this will get the root user then you can you can user.confirm() and after that user.save this solved my problem. (this will also allow you to change the default email by user.email = "[email protected]"

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