catch entering username as an email instead of returning a 500 error

Summary

When creating a new User, if an email address is entered as the Username then on save a 500 error is returned.

Steps to reproduce

  • Create User - use an email address as the Username. e.g. Username=john.smith@example.com OR use any name with spaces like John Doe in the Username field.

What is the current bug behavior?

A 500 error page is returned.

What is the expected correct behavior?

Disallow email being used as Username before Saving.

Relevant logs and/or screenshots

==> /var/log/gitlab/gitlab-rails/production_json.log <==
{"method":"POST","path":"/admin/users","format":"html","controller":"Admin::UsersController","action":"create","status":500,"error":"ActionView::Template::Error: No route matches {:action=>\"reset_runners_minutes\", :controller=>\"admin/users\", :id=>#<User id: @ufour@example.com>} missing required keys: [:id]","duration":443.06,"view":0.0,"db":110.09,"time":"2018-02-28T09:14:24.751Z","params":{"utf8":"✓","authenticity_token":"[FILTERED]","user":{"name":"ufour","username":"ufour@example.com","email":"ufour@example.com","projects_limit":"10","can_create_group":"1","access_level":"regular","external":"0","skype":"","linkedin":"","twitter":"","website_url":"","note":""}},"remote_ip":"172.17.0.1","user_id":1,"username":"root"}

==> /var/log/gitlab/gitlab-workhorse/current <==
2018-02-28_09:14:25.20296 gitlab-ee-10.4.4:9090 @ - - [2018-02-28 09:14:24.723160145 +0000 UTC m=+2652.997457675] "POST /admin/users HTTP/1.1" 500 2902 "http://gitlab-ee-10.4.4:9090/admin/users/new" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36" 0.479644

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

System information System: Ubuntu 16.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.3.6p384 Gem Version: 2.6.13 Bundler Version:1.13.7 Rake Version: 12.3.0 Redis Version: 3.2.11 Git Version: 2.14.3 Sidekiq Version:5.0.5 Go Version: unknown

GitLab information Version: 10.5.2-ee Revision: 3834bbe Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.5 URL: https://astrachan-latest.asgks.net HTTP Clone URL: https://astrachan-latest.asgks.net/some-group/some-project.git SSH Clone URL: git@astrachan-latest.asgks.net:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: saml

GitLab Shell Version: 6.0.3 Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab Shell ...

GitLab Shell version >= 6.0.3 ? ... OK (6.0.3) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... ... Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Reply by email is disabled in config/gitlab.yml Checking LDAP ...

Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) ... Checking LDAP ... Finished

Checking GitLab ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... ... Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.3.6) Git version >= 2.9.5 ? ... yes (2.14.3) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1519809492 sudo mv /var/opt/gitlab/.ssh/id_rsa.pub ~/gitlab-check-backup-1519809492 sudo mv /var/opt/gitlab/.ssh/id_rsa ~/gitlab-check-backup-1519809492 For more information see: doc/ssh/README.md in section "SSH on the GitLab server" Please fix the error above and rerun the checks. Active users: ... 9 Elasticsearch version 5.1 - 5.5? ... skipped (elasticsearch is disabled)

Checking GitLab ... Finished

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Edited by Alexandr Tanayno