git服务部署在CentOS7和gitlab-ce 7.10.0-omnibus.2
- 超级管理员密码遗忘
[root@ycx bin]# gitlab-rails console production
管理控制台输入,查找id为1的用户,即为默认的超级用户/管理员信息。也可以使用User.find_by(email: '[email protected]')根据邮箱信息进行查找。
irb(main):001:0> user = User.where(id: 1).first
结果如下:
=> #<User id: 1, email: "######@dingtalk.com", encrypted_password: "$2a$10$qqfJ8mbiS/e6G5NfFwji.e96jsGLqw2ox3xnkfusmuW...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 9, current_sign_in_at: "2018-03-07 02:31:43", last_sign_in_at: "2017-11-02 07:49:40", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2017-10-13 15:08:14", updated_at: "2018-03-07 02:36:00", name: "admin", admin: true, projects_limit: 10000, skype: "", linkedin: "", twitter: "", authentication_token: "ekRH377HhNt5gpaTruoq", theme_id: 3, bio: "", failed_attempts: 0, locked_at: nil, username: "root", can_create_group: true, can_create_team: false, state: "active", color_scheme_id: 4, notification_level: 1, password_expires_at: nil, created_by_id: nil, last_credential_check_at: nil, avatar: nil, confirmation_token: nil, confirmed_at: "2017-10-13 15:08:15", confirmation_sent_at: "2017-10-13 15:08:15", unconfirmed_email: nil, hide_no_ssh_key: false, website_url: "", github_access_token: nil, gitlab_access_token: nil, notification_email: "######@dingtalk.com", hide_no_password: false, password_automatically_set: false, bitbucket_access_token: nil, bitbucket_access_token_secret: nil, location: "", public_email: "">
重设并保存新密码
irb(main):001:0> user.password = 'new_pwd' irb(main):001:0> user.save!
重启gitlab服务
[root@ycx bin]# gitlab-ctl restart
- 无法创建新用户
创建用户页面,执行保存时直接返回500。
tail命令在producted.log中发现有如下错误:
Started POST "/admin/users" for 127.0.0.1 at 2018-03-07 13:12:06 +0800 Processing by Admin::UsersController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"name"=>"zhaolijun", "username"=>"zhaolijun", "email"=>"zhaolijun", "projects_limit"=>"10", "can_create_group"=>"1", "admin"=>"0", "skype"=>"", "linkedin"=>"", "twitter"=>"", "website_url"=>""}} Completed 500 Internal Server Error in 198ms NoMethodError (undefined method `skip_confirmation!' for #<User:0x0000000dca8778>): app/controllers/admin/users_controller.rb:51:in `create'
第一次接触ruby,根据其他代码经验。
修改
/opt/gitlab/embedded/service/gitlab-rails/app/controllers/admin/users_controller.rb
注释
# @user.skip_confirmation!
修改页面验证
/opt/gitlab/embedded/service/gitlab-rails/app/views/admin/users/_form.html.haml
搜索 f.text_field :email, required: true
修改为 f.text_field :email, required: false