diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /app/controllers/profiles | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r-- | app/controllers/profiles/passwords_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/profiles/personal_access_tokens_controller.rb | 33 |
2 files changed, 12 insertions, 27 deletions
diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 5eb0f80ddc9..738c41207d5 100644 --- a/app/controllers/profiles/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Profiles::PasswordsController < Profiles::ApplicationController + include Gitlab::Tracking::Helpers::WeakPasswordErrorEvent + skip_before_action :check_password_expiration, only: [:new, :create] skip_before_action :check_two_factor_requirement, only: [:new, :create] @@ -27,6 +29,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController redirect_to root_path, notice: _('Password successfully changed') else + track_weak_password_error(@user, self.class.name, 'create') render :new end end @@ -48,6 +51,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController flash[:notice] = _('Password was successfully updated. Please sign in again.') redirect_to new_user_session_path else + track_weak_password_error(@user, self.class.name, 'update') @user.reset render 'edit' end @@ -94,3 +98,5 @@ class Profiles::PasswordsController < Profiles::ApplicationController } end end + +Profiles::PasswordsController.prepend_mod diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb index 4cf26d3e1e2..1663aa61f62 100644 --- a/app/controllers/profiles/personal_access_tokens_controller.rb +++ b/app/controllers/profiles/personal_access_tokens_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Profiles::PersonalAccessTokensController < Profiles::ApplicationController + include RenderAccessTokens + feature_category :authentication_and_authorization before_action :check_personal_access_tokens_enabled @@ -16,7 +18,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController respond_to do |format| format.html format.json do - render json: @active_personal_access_tokens + render json: @active_access_tokens end end end @@ -30,7 +32,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController if result.success? render json: { new_token: @personal_access_token.token, - active_access_tokens: active_personal_access_tokens }, status: :ok + active_access_tokens: active_access_tokens }, status: :ok else render json: { errors: result.errors }, status: :unprocessable_entity end @@ -56,36 +58,13 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController def set_index_vars @scopes = Gitlab::Auth.available_scopes_for(current_user) - @active_personal_access_tokens = active_personal_access_tokens + @active_access_tokens = active_access_tokens end - def active_personal_access_tokens - tokens = finder(state: 'active', sort: 'expires_at_asc_id_desc').execute - - if Feature.enabled?('access_token_pagination') - tokens = tokens.page(page) - add_pagination_headers(tokens) - end - + def represent(tokens) ::PersonalAccessTokenSerializer.new.represent(tokens) end - def add_pagination_headers(relation) - Gitlab::Pagination::OffsetHeaderBuilder.new( - request_context: self, - per_page: relation.limit_value, - page: relation.current_page, - next_page: relation.next_page, - prev_page: relation.prev_page, - total: relation.total_count, - params: params.permit(:page) - ).execute - end - - def page - (params[:page] || 1).to_i - end - def check_personal_access_tokens_enabled render_404 if Gitlab::CurrentSettings.personal_access_tokens_disabled? end |