Commit Graph
397 Commits
Author SHA1 Message Date
Rémy Coutable b3635ee46a Re-add EmailValidator to avoid the repetition of format: { with: Devise.email_regexp } 2016-02-09 18:15:35 +01:00
Rémy Coutable b34963bc12 Validate email addresses using Devise.email_regexp
Also:
- Get rid of legacy :strict_mode
- Get rid of custom :email validator
- Add some shared examples to spec emails validation
2016-02-09 18:15:35 +01:00
Douglas Barbosa Alexandre e38a1fc83e Fix typo on User model 2016-02-02 11:25:44 -02:00
Stan HuandDouglas Barbosa Alexandre d20e75a8d8 Support Akismet spam checking for creation of issues via API
Currently any spam detected by Akismet by non-members via API will be logged
in a separate table in the admin page.

Closes #5612
2016-02-02 11:25:44 -02:00
Douwe Maan 98e1a5b634 Allow LDAP users to change their email if it was not set by the LDAP server 2016-01-19 16:25:38 +01:00
Gabriel Mazetto dd6fc01ff8 fixed LDAP activation on login to use new ldap_blocked state 2016-01-14 03:31:27 -02:00
Gabriel Mazetto ec67e9be1d Repair ldap_blocked state when no ldap identity exist anymore 2016-01-08 16:26:04 -02:00
Gabriel Mazetto bc7ef8e5b7 Add ldap_blocked as new state to users state machine 2016-01-08 16:26:04 -02:00
Stan Hu 79c0e7212a Annotate models 2016-01-06 13:09:55 +00:00
Robert Speicher fd178c1e7d Prevent duplicate "username has already been taken" validation message
Closes #201 - two-year-old bug, woo! 💥 🎉
2016-01-02 20:03:28 -05:00
Robert Speicher 9570495e75 Merge branch 'add_email_unlock' into 'master'
Allow account unlock via email

We see a lot of users get confused about what it means when your account gets
locked. Many try to reset their password and are still faced with a lockout.
With this change, users receive an email that allows them to unlock their
account immediately. The previous behavior where the account is auto-unlocked
after a time also still works.

See merge request !2049
2015-12-21 17:53:20 +00:00
Gabriel Mazetto b5291f9599 Fixed Rubocop offenses 2015-12-15 00:53:52 -02:00
Drew Blessing be41d84fb0 Allow account unlock via email 2015-12-14 15:35:02 -06:00
Grzegorz Bizon 2ec93abed7 Merge branch 'master' into ci/persist-registration-token
* master: (66 commits)
  Fix runners admin view
  Fix migrations
  Rename mention of gitlab-git-http-server to gitlab-workhorse
  Bump Redis requirement to 2.8 for Sidekiq 4 requirements
  Fix wording on runner setup page
  add details on how to change saml button label
  Fix tests
  Move awards back to gray panel and few improvements to sidebar
  Few UI improvements to new sidebar implementation
  Fix tests for new issuable sidebar
  Update changelog
  Implement new sidebar for merge request page
  Make edit link on issuable sidebar works
  Redesign issue page for new sidebar
  Move awards css to separate file
  Implement issuable sidebar partial
  Update CHANGELOG
  Clarify cache behavior
  Run builds from projects with enabled CI
  Use Gitlab::Git instead of Ci::Git
  ...

Conflicts:
	db/schema.rb
2015-12-14 12:26:40 +01:00
Kamil Trzcinski 64bfd9d71a Remove ci_ prefix from all ci related things 2015-12-11 18:02:09 +01:00
Kamil Trzcinski e80e3f5372 Migrate CI::Project to Project 2015-12-11 18:02:09 +01:00
Grzegorz Bizon 9948e5bcdd Refactor TokenAuthenticatable to improve reusability
This adds a ability to use multiple different authentication token
fields in other models. From now on it is necessary to add
authentication token field manually in each class that implements this
mixin.
2015-12-11 10:39:39 +01:00
Stan Hu 9dbc768db8 Update annotations 2015-12-08 21:00:01 -08:00
Robert Speicher 9321d382bd Add custom NamespaceValidator 2015-12-07 16:57:26 -05:00
Valery Sizov 162cd0099c fix deprecation messages in tests 2015-12-03 10:33:43 +02:00
Valery Sizov e6dadea389 git rid of deprecated warnings 2015-12-02 08:50:00 +02:00
Stan Hu 2f90e71fd3 Merge pull request #9670 from janten/gravatar-retina
Add support for HiDPI displays in gravatar service
2015-11-26 08:13:28 -08:00
Yorick Peterse efd5d93745 Use "GitLab.com" instead of "gitlab.com" 2015-11-18 20:20:55 +01:00
Yorick Peterse 26482bddb0 Don't pluck project IDs in User#owned_projects
This won't work efficiently if you happen to have a lot of projects.
2015-11-18 13:12:44 +01:00
Yorick Peterse 73f302edf9 Apply CI scope changes to the User model
These changes are based on those from commit
03f5ff750b, except they use a UNION
instead of plucking IDs into memory.
2015-11-18 13:05:45 +01:00
Yorick Peterse e116a356b8 Refactor User#authorized_groups/projects
These methods no longer include public groups/projects (that don't
belong to the actual user) as this is handled by the various finder
classes now. This also removes the need for passing extra arguments.

Note that memoizing was removed _explicitly_. For whatever reason doing
so messes up the users controller to a point where it claims a certain
user does _not_ have access to certain groups/projects when it does have
access. Existing code shouldn't be affected as these methods are only
called in ways that they'd run queries anyway (e.g. a combination of
"any?" and "each" which would run 2 queries regardless of memoizing).
2015-11-18 13:05:45 +01:00
Yorick Peterse 5fcd9986b8 Refactor getting user groups/projects/contributions
This new setup no longer loads any IDs into memory using "pluck",
instead using SQL UNIONs to merge the various datasets together. This
results in greatly improved query performance as well as a reduction of
memory usage.

The old setup was in particular problematic when requesting the
authorized projects _including_ public/internal projects as this would
result in roughly 65000 project IDs being loaded into memory. These IDs
would in turn be passed to other queries.
2015-11-18 13:05:45 +01:00
Yorick Peterse bfd9855a2b Prefix table names for User UNIONs 2015-11-18 13:05:45 +01:00
Yorick Peterse 189c40c33d Use SQL::Union for User#authorized_groups
This removes the need for plucking any IDs into Ruby.
2015-11-18 13:05:45 +01:00
Yorick Peterse 028bd227fb Use SQL::Union for User#authorized_projects
This allows retrieving of the list of authorized projects using a single
query, without having to load any IDs into Ruby. This in turn also means
we can remove the method User#authorized_projects_id.
2015-11-18 13:05:45 +01:00
Kamil Trzcinski 03f5ff750b Show specific runners from projects where user is master or owner 2015-11-16 13:24:56 +01:00
Dmitriy Zaporozhets a237999f00 Annotate models
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-13 19:22:46 +01:00
Yorick Peterse a9df714764 Use a subquery with IDs only for find_by_any_email
This further improves performance of User.find_by_any_email and is
roughly twice as fast as the previous UNION setup.

Thanks again to @dlemstra for suggesting this.
2015-10-30 12:00:58 +01:00
Yorick Peterse bba46623c2 Fixed UNION syntax for MySQL
MySQL doesn't support the previous syntax.
2015-10-30 12:00:58 +01:00
Yorick Peterse 24c8f42278 Use a UNION for User.find_by_any_email
This is significantly faster than using a sub-query, at least when run
on the GitLab.com production database. The benchmarks are a lot slower
now with these changes, most likely due to PostgreSQL choosing a
different (and less efficient) plan based on the amount of data present
in the test database.

Thanks to @dlemstra for suggesting the use of a UNION.
2015-10-30 12:00:58 +01:00
Yorick Peterse 49c081b9f3 Improve performance of User.find_by_any_email
This query used to rely on a JOIN, effectively producing the following
SQL:

    SELECT users.*
    FROM users
    LEFT OUTER JOIN emails ON emails.user_id = users.id
    WHERE (users.email = X OR emails.email = X)
    LIMIT 1;

The use of a JOIN means having to scan over all Emails and users, join
them together and then filter out the rows that don't match the criteria
(though this step may be taken into account already when joining).

In the new setup this query instead uses a sub-query, producing the
following SQL:

    SELECT *
    FROM users
    WHERE id IN (select user_id FROM emails WHERE email = X)
    OR email = X
    LIMIT 1;

This query has the benefit that it:

1. Doesn't have to JOIN any rows
2. Only has to operate on a relatively small set of rows from the
   "emails" table.

Since most users will only have a handful of Emails associated
(certainly not hundreds or even thousands) the size of the set returned
by the sub-query is small enough that it should not become problematic.

Performance of the old versus new version can be measured using the
following benchmark:

    # Save this in ./bench.rb
    require 'benchmark/ips'

    email = 'yorick@gitlab.com'

    def User.find_by_any_email_old(email)
      user_table = arel_table
      email_table = Email.arel_table

      query = user_table.
        project(user_table[Arel.star]).
        join(email_table, Arel::Nodes::OuterJoin).
        on(user_table[:id].eq(email_table[:user_id])).
        where(user_table[:email].eq(email).or(email_table[:email].eq(email)))

      find_by_sql(query.to_sql).first
    end

    Benchmark.ips do |bench|
      bench.report 'original' do
        User.find_by_any_email_old(email)
      end

      bench.report 'optimized' do
        User.find_by_any_email(email)
      end

      bench.compare!
    end

Running this locally using "bundle exec rails r bench.rb" produces the
following output:

    Calculating -------------------------------------
                original     1.000  i/100ms
               optimized    93.000  i/100ms
    -------------------------------------------------
                original     11.103  (± 0.0%) i/s -     56.000
               optimized    948.713  (± 5.3%) i/s -      4.743k

    Comparison:
               optimized:      948.7 i/s
                original:       11.1 i/s - 85.45x slower

In other words, the new setup is 85x faster compared to the old setup,
at least when running this benchmark locally.

For GitLab.com these improvements result in User.find_by_any_email
taking only ~170 ms to run, instead of around 800 ms. While this is
"only" an improvement of about 4.5 times (instead of 85x) it's still
significantly better than before.

Fixes #3242
2015-10-30 12:00:58 +01:00
Kamil Trzcinski 6db014987d Fix specific runner visibility 2015-10-26 11:23:11 +01:00
Jan-Gerd Tenberge b5c19bcc4d Fix merge error 2015-10-22 21:43:17 +02:00
Dmitriy Zaporozhets a148c06cf8 Merge branch 'cristianbica/gitlab-ce-user-project-view-files' into 'master'
Allow users to select the Files view as default project view


![Screen_Shot_2015-10-17_at_19.24.01](/uploads/c3194db856f5e5e1b3493302c0a479a5/Screen_Shot_2015-10-17_at_19.24.01.png)

Also shows the readme at the very bottom, like on the regular Files page.


Replaces !1489.

Closes #2655.

See merge request !1632
2015-10-19 09:27:37 +00:00
Douwe Maan 70240f433c Merge branch 'master' into cristianbica/gitlab-ce-user-project-view-files 2015-10-17 18:20:04 +02:00
Stan Hu ca3ce5c26c Fix nonatomic database update potentially causing project star counts to go negative
The counter_cache decrement function is called when a project star is deleted,
but there was no guarantee multiple workers would not attempt to delete the
same item simultaneously. Use an atomic update to prevent the count from going negative.

Closes #3067
2015-10-17 00:58:14 -07:00
Yorick Peterse 72f428c7d2 Improve performance of User.by_login
Performance is improved in two steps:

1. On PostgreSQL an expression index is used for checking lower(email)
   and lower(username).
2. The check to determine if we're searching for a username or Email is
   moved to Ruby. Thanks to @haynes for suggesting and writing the
   initial implementation of this.

Moving the check to Ruby makes this method an additional 1.5 times
faster compared to doing the check in the SQL query.

With performance being improved I've now also tweaked the amount of
iterations required by the User.by_login benchmark. This method now runs
between 900 and 1000 iterations per second.
2015-10-15 11:58:25 +02:00
Dmitriy Zaporozhets 3d90560c1e Merge branch 'user-preferences-layout-option' of https://github.com/gopeter/gitlabhq into gopeter-user-preferences-layout-option
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-10-05 20:14:32 +02:00
Peter Göbel 291e1fa930 improved code style and layout option naming 2015-10-05 18:09:05 +02:00
Peter Göbel e2c5d08e7e added user preference to change layout width 2015-10-05 17:22:47 +02:00
Kamil Trzcinski e3d870d7fc Add user to Ci::Build to have pusher email address 2015-10-05 10:15:40 +02:00
Guilherme Garnier 1cfb48ddd0 Merge remote-tracking branch 'upstream/master' 2015-10-03 11:46:29 -05:00
Guilherme Garnier 2b075f16c7 Fix rubocop warnings in app 2015-10-03 00:56:37 -05:00
Douwe Maan 93522e59ec Merge branch 'rs-throttle-reset' into 'master'
Throttle "Forgot your password?" emails

Addresses internal https://dev.gitlab.org/gitlab/gitlabhq/issues/2611

See merge request !1476
2015-10-02 14:37:07 +00:00
Robert Speicher ad7ad8745a Add User#recently_sent_password_reset? 2015-10-01 21:41:56 -04:00