Reputation: 2541
While I am waiting for a merge request to be introduced to Gitlab to avoid this problem I need a workaround to edit an user's email address via the gitlab-rails console.
Using this:
user = User.find_by(name: 'test')
user.email = '[email protected]'
user.save
allows to edit the user but I am asked to confirm the new email before it is applied. Any idea?
Upvotes: 3
Views: 4755
Reputation: 1
https://docs.gitlab.com/ee/api/users.html#user-modification
The email field is the user’s primary email address. You can only change this field to an already-added secondary email address for that user. To add more email addresses to the same user, use the add email function.
i face same problem.. so i research document and find this. we cannot change primary email
Upvotes: 0
Reputation: 1323753
You might have another option with GitLab 15.5 (October 2022)
Modify user’s commit email through the Users API
Previously, a user’s commit email could be modified only in the UI.
Now, administrators can use the Users API to modify the commit email and perform this as a bulk action.
Thank you Neil Drumm for your contribution!
See Documentation and Issue.
Context:
In the Drupal community we provision contributor user accounts in our GitLab instance (
git.drupalcode.org
) automatically from theirDrupal.org
user accounts.In the past, we used
Drupal.org
to manage multiple email accounts per user, and to provide a no-reply 'private
' commit email.We would like to migrate multiple email account handling to GitLab, but at the same time we want to be able to bulk set the public
commit_email
of users to the GitLab providedno-reply
address to preserve privacy.
Upvotes: 0
Reputation: 2541
I found it afterwards, so in case someone has the same problem:
gitlab-rails runner '
user = User.find_by(name: 'test')
user.email = '[email protected]'
user.skip_reconfirmation!
user.save
'
EDIT: This used to work in old version, but is no longer required as I contributed to add a skip confirmation when using the Users API: https://docs.gitlab.com/ee/api/users.html#add-email-for-user
Upvotes: 6