Commit Graph

353 Commits

Author SHA1 Message Date
Dmitriy Zaporozhets c85c0ccc8d
Merge branch 'mdelaossa/gitlab-ce-31995-project-limit-default-fix'
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-01-04 19:35:14 +02:00
Francisco Javier López 2665aea627 Fix user membership destroy relation 2018-01-02 15:06:44 +00:00
Mario de la Ossa 75cf5f5b54
User#projects_limit remove DB default and added NOT NULL constraint
This change is required because otherwise if a user is created with a
value for `projects_limit` that matches the DB default, it gets
overwritten by `current_application_settings.default_projects_limit`. By
removing the default we once again can allow a user to be created with a
limit of 10 projects without the risk that it'll change to 10000
2017-12-30 14:33:49 -06:00
blackst0ne 27c95364b5 Replace '.team << [user, role]' with 'add_role(user)' in specs 2017-12-22 19:18:28 +11:00
Robert Speicher 32ff813d3d Add BlocksJsonSerialization model concern and include it in User 2017-12-19 15:45:07 -06:00
Douwe Maan 8c0aa7d4a7 Merge branch 'bvl-10-2-email-disclosure' into 'security-10-2'
(10.2) Avoid partial partial email adresses for matching

See merge request gitlab/gitlabhq!2232

(cherry picked from commit 081aa1e91a777c9acb31be4a1e76b3dd7032fa9a)

There are unresolved conflicts in app/models/user.rb.

fa85a3fd Don't allow searching for partial user emails
2017-12-08 13:47:18 -08:00
Mayra Cabrera 562fb460b8 Allow git pull/push on project redirects 2017-12-08 17:42:43 +00:00
Mike Greiling 2c569be63b Resolve "Display member role per project" 2017-12-07 09:11:41 +00:00
Markus Koller 257fd57134 Allow password authentication to be disabled entirely 2017-11-23 13:16:14 +00:00
Yorick Peterse 3e561736b2
Cache the number of user SSH keys
By caching the number of personal SSH keys we reduce the number of
queries necessary on pages such as ProjectsController#show (which can
end up querying this data multiple times).

The cache is refreshed/flushed whenever an SSH key is added, removed, or
when a user is removed.
2017-11-16 14:59:38 +01:00
Bob Van Landuyt 022d8420ec Include child projects a user can manage in namespace dropdowns
These dropdown options are used for creating and transfering projects.
2017-11-14 16:57:41 +01:00
Douwe Maan 2fbbba9a29 Always return full avatar URL for private/internal groups/projects when asset host is set 2017-11-09 15:40:41 +00:00
Yorick Peterse 44be82dd18
Refactor User.find_by_any_email
By using SQL::Union we can return a proper ActiveRecord::Relation,
making it possible to select the columns we're interested in (instead of
all of them).
2017-11-07 22:28:52 +01:00
Douwe Maan 634a152760 Make sure group and project creation is blocked for new users that are external by default 2017-11-06 15:19:15 +01:00
Winnie Hellmann 6f1a4ba457 Add system hooks user_rename and group_rename 2017-11-03 11:26:52 +00:00
Douwe Maan 294fa6fcdc Remove authentication using user.private_token 2017-11-02 11:39:02 +01:00
Jacopo 0ce6785851 Replaces `tag: true` into `:tag` in the specs
Replaces all the explicit include metadata syntax in the specs (tag:
true) into the implicit one (:tag).
Added a cop to prevent future errors and handle autocorrection.
2017-10-07 13:57:54 +02:00
Bob Van Landuyt f90b27da77 Find forks within users/namespaces using fork memberships 2017-10-07 11:46:23 +02:00
Bob Van Landuyt e8ca579d88 Add a project forks spec helper
The helper creates a fork of a project with all provided attributes,
but skipping the creation of the repository on disk.
2017-10-07 11:46:23 +02:00
Winnie Hellmann 265b1a3b72 Show confirmation modal before deleting account 2017-10-06 20:40:41 +00:00
Douwe Maan 782c017ca0 Make sure spec expectations are in their own paragraphs 2017-10-05 12:58:21 +02:00
Douwe Maan 0c0c2ecd99 Merge branch 'master' into digitalmoksha/gitlab-ce-feature/verify_secondary_emails
# Conflicts:
#	app/controllers/admin/users_controller.rb
#	app/controllers/confirmations_controller.rb
#	app/controllers/profiles/emails_controller.rb
#	app/models/user.rb
#	app/services/emails/base_service.rb
#	app/services/emails/destroy_service.rb
#	app/views/devise/mailer/confirmation_instructions.html.haml
#	lib/api/users.rb
#	spec/services/emails/destroy_service_spec.rb
2017-10-05 12:48:22 +02:00
Markus Koller e9eae3eb0d Support custom attributes on users 2017-09-28 16:49:42 +00:00
Brett Walker d97b577a1b must now set the devise default scope (since we now have an :email scope)
and rubocop fixes
2017-09-24 19:52:49 +02:00
Brett Walker d7d335c05b add primary email as a secondary email whenever the primary is changed 2017-09-23 15:26:04 +02:00
Brett Walker 665c7876fa added email.confirmed scope and fix email comparison 2017-09-23 15:26:04 +02:00
Brett Walker ed99c899a2 allow a verified secondary email to be use as the primary without
a reconfirmation
2017-09-23 15:26:04 +02:00
Brett Walker a32f1dddf2 fixes for rubocop 2017-09-23 15:26:04 +02:00
Brett Walker 85d2bf778a when a primary email is replaced and added to the secondary emails list,
make sure it stays confirmed
2017-09-23 15:24:53 +02:00
Brett Walker 09726bdf44 small cleanup changes based on feedback 2017-09-23 15:24:53 +02:00
Brett Walker a9b3178697 Make GPG signature verification work with non-primary email (#36959) 2017-09-23 15:24:53 +02:00
Annabel Dunstone Gray 9b177bb7c9 Revert "Merge branch 'revert-f2421b2b' into 'master'"
This reverts merge request !14148
2017-09-11 15:44:42 +00:00
Douwe Maan 5cc140b202 Merge branch 'user-recent-push' into 'master'
Rework how recent push events are retrieved

Closes #35990

See merge request !13995
2017-09-11 09:40:59 +00:00
Rubén Dávila 52a2423e37 Revert "Merge branch '35012-navigation-add-option-to-change-navigation-color-palette' into 'master'"
This reverts merge request !13619
2017-09-08 14:48:44 +00:00
Yorick Peterse 83355336dd
Rework how recent push events are retrieved
Whenever you push to a branch GitLab will show a button to create a
merge request (should one not exist already). The underlying code to
display this data was quite inefficient. For example, it involved
multiple slow queries just to figure out what the most recent push event
was.

This commit changes the way this data is retrieved so it's much faster.
This is achieved by caching the ID of the last push event on every push,
which is then retrieved when loading certain pages. Database queries are
only executed if necessary and the cached data is removed automatically
once a merge request has been created, or 2 hours after being stored.

A trade-off of this approach is that we _only_ track the last event.
Previously if you were to push to branch A and B then create a merge
request for branch B we'd still show the widget for branch A. As of this
commit this is no longer the case, instead we will only show the widget
for the branch you pushed to most recently. Once a merge request exists
the widget is no longer displayed. Alternative solutions are either too
complex and/or too slow, hence the decision was made to settle for this
trade-off.

Performance Impact
------------------

In the best case scenario (= a user didn't push anything for more than 2
hours) we perform a single Redis GET per page. Should there be cached
data we will run a single (and lightweight) SQL query to get the
event data from the database. If a merge request already exists we will
run an additional DEL to remove the cache key.

The difference in response timings can vary a bit per project. On
GitLab.com the 99th percentile of time spent in User#recent_push hovers
between 100 milliseconds and 1 second, while the mean hovers around 50
milliseconds. With the changes in this MR the expected time spent in
User#recent_push is expected to be reduced down to just a few
milliseconds.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/35990
2017-09-08 00:46:16 +02:00
Douwe Maan 523a1c69ab Merge branch '23079-remove-default-scope-in-sortable' into 'master'
Removes default scope from sortable

Closes #23079

See merge request !13558
2017-09-07 16:15:32 +00:00
Annabel Dunstone Gray 99dcf870dd Use indigo as default theme 2017-09-07 06:43:12 -07:00
Tiago Botelho cfd475a45e Removes default scope from sortable 2017-09-07 13:01:59 +01:00
Annabel Dunstone Gray 7b567597ee Fix specs; start on light theme 2017-09-06 12:57:30 -05:00
Rubén Dávila 6c49a62800 Restore some changes from !9199 2017-09-06 12:54:09 -05:00
Alexander Keramidas 4df54f2607 Profile updates from providers 2017-09-06 16:38:52 +03:00
Alexis Reigel 98016ef7f3 add User##verified_email? method 2017-09-05 12:18:32 +02:00
Yorick Peterse 8274e0fe3c Merge branch 'improve-autocomplete-user-performance' into 'master'
Improve AutocompleteController#users.json performance

Closes #36879

See merge request !13754
2017-08-30 11:17:10 +00:00
Hiroyuki Sato 9e203582b3 Improve AutocompleteController#user.json performance 2017-08-25 18:41:43 +09:00
Andrew Newdigate fb49c94e49 Delegate Repository::branch_exists? and ref_exists? to Gitlab::Git 2017-08-24 09:20:04 +00:00
Michael Kozono bd578d96b4 Add namespace errors from User#after_update 2017-08-18 10:31:59 -07:00
Michael Kozono 82bafd002d Make username update fail if namespace part fails 2017-08-17 13:18:02 -07:00
Yorick Peterse 0395c47193
Migrate events into a new format
This commit migrates events data in such a way that push events are
stored much more efficiently. This is done by creating a shadow table
called "events_for_migration", and a table called "push_event_payloads"
which is used for storing push data of push events. The background
migration in this commit will copy events from the "events" table into
the "events_for_migration" table, push events in will also have a row
created in "push_event_payloads".

This approach allows us to reclaim space in the next release by simply
swapping the "events" and "events_for_migration" tables, then dropping
the old events (now "events_for_migration") table.

The new table structure is also optimised for storage space, and does
not include the unused "title" column nor the "data" column (since this
data is moved to "push_event_payloads").

== Newly Created Events

Newly created events are inserted into both "events" and
"events_for_migration", both using the exact same primary key value. The
table "push_event_payloads" in turn has a foreign key to the _shadow_
table. This removes the need for recreating and validating the foreign
key after swapping the tables. Since the shadow table also has a foreign
key to "projects.id" we also don't have to worry about orphaned rows.

This approach however does require some additional storage as we're
duplicating a portion of the events data for at least 1 release. The
exact amount is hard to estimate, but for GitLab.com this is expected to
be between 10 and 20 GB at most. The background migration in this commit
deliberately does _not_ update the "events" table as doing so would put
a lot of pressure on PostgreSQL's auto vacuuming system.

== Supporting Both Old And New Events

Application code has also been adjusted to support push events using
both the old and new data formats. This is done by creating a PushEvent
class which extends the regular Event class. Using Rails' Single Table
Inheritance system we can ensure the right class is used for the right
data, which in this case is based on the value of `events.action`. To
support displaying old and new data at the same time the PushEvent class
re-defines a few methods of the Event class, falling back to their
original implementations for push events in the old format.

Once all existing events have been migrated the various push event
related methods can be removed from the Event model, and the calls to
`super` can be removed from the methods in the PushEvent model.

The UI and event atom feed have also been slightly changed to better
handle this new setup, fortunately only a few changes were necessary to
make this work.

== API Changes

The API only displays push data of events in the new format. Supporting
both formats in the API is a bit more difficult compared to the UI.
Since the old push data was not really well documented (apart from one
example that used an incorrect "action" nmae) I decided that supporting
both was not worth the effort, especially since events will be migrated
in a few days _and_ new events are created in the correct format.
2017-08-10 17:45:44 +02:00
Michael Kozono 255be6c5ca Prevent user from changing username with container registry tags 2017-08-09 16:24:49 +00:00
Yorick Peterse ab738645a7
Memoize a user's personal projects count
The method User#projects_limit_left would run "personal_projects.count"
but such a query is not memoized. As a result multiple calls to
User#projects_limit_left would result in multiple COUNT(*) queries being
executed.

To work around this this commit adds User#personal_projects_count which
simply memoizes the result of the COUNT(*) in an instance variable.
2017-08-07 12:38:32 +02:00