diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-21 09:11:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-21 09:11:50 +0300 |
commit | a293ae1ab5e4253f6003123c79c00bf7b953a7e5 (patch) | |
tree | fd85a2f53f245787b3190d31b4e31f17b3dc2444 /app | |
parent | e3ecb7dc093db47b9491e20d9f20de02b4ac2b6d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
5 files changed, 62 insertions, 8 deletions
diff --git a/app/assets/javascripts/admin/abuse_report/components/user_details.vue b/app/assets/javascripts/admin/abuse_report/components/user_details.vue index 0c32341652b..0e946fed8ac 100644 --- a/app/assets/javascripts/admin/abuse_report/components/user_details.vue +++ b/app/assets/javascripts/admin/abuse_report/components/user_details.vue @@ -26,12 +26,18 @@ export default { .map(([k]) => this.$options.i18n.verificationMethods[k]) .join(', '); }, - showSimilarRecords() { + showCreditCardSimilarRecords() { return this.user.creditCard.similarRecordsCount > 1; }, - similarRecordsCount() { + creditCardSimilarRecordsCount() { return formatNumber(this.user.creditCard.similarRecordsCount); }, + showPhoneNumberSimilarRecords() { + return this.user.phoneNumber.similarRecordsCount > 1; + }, + phoneNumberSimilarRecordsCount() { + return formatNumber(this.user.phoneNumber.similarRecordsCount); + }, }, i18n: USER_DETAILS_I18N, }; @@ -60,11 +66,33 @@ export default { data-testid="credit-card-verification" :label="$options.i18n.creditCard" > - <gl-sprintf v-if="showSimilarRecords" :message="$options.i18n.similarRecords"> + <gl-sprintf + v-if="showCreditCardSimilarRecords" + :message="$options.i18n.creditCardSimilarRecords" + > <template #cardMatchesLink="{ content }"> <gl-link :href="user.creditCard.cardMatchesLink"> <gl-sprintf :message="content"> - <template #count>{{ similarRecordsCount }}</template> + <template #count>{{ creditCardSimilarRecordsCount }}</template> + </gl-sprintf> + </gl-link> + </template> + </gl-sprintf> + </user-detail> + + <user-detail + v-if="user.phoneNumber" + data-testid="phone-number-verification" + :label="$options.i18n.phoneNumber" + > + <gl-sprintf + v-if="showPhoneNumberSimilarRecords" + :message="$options.i18n.phoneNumberSimilarRecords" + > + <template #phoneMatchesLink="{ content }"> + <gl-link :href="user.phoneNumber.phoneMatchesLink"> + <gl-sprintf :message="content"> + <template #count>{{ phoneNumberSimilarRecordsCount }}</template> </gl-sprintf> </gl-link> </template> diff --git a/app/assets/javascripts/admin/abuse_report/constants.js b/app/assets/javascripts/admin/abuse_report/constants.js index c56ea678b1d..69bcdebad61 100644 --- a/app/assets/javascripts/admin/abuse_report/constants.js +++ b/app/assets/javascripts/admin/abuse_report/constants.js @@ -61,6 +61,7 @@ export const USER_DETAILS_I18N = { plan: s__('AbuseReport|Tier'), verification: s__('AbuseReport|Verification'), creditCard: s__('AbuseReport|Credit card'), + phoneNumber: s__('AbuseReport|Phone number'), pastReports: s__('AbuseReport|Past abuse reports'), normalLocation: s__('AbuseReport|Normal location'), lastSignInIp: s__('AbuseReport|Last login'), @@ -78,9 +79,12 @@ export const USER_DETAILS_I18N = { reportedFor: s__( 'AbuseReport|%{reportLinkStart}Reported%{reportLinkEnd} for %{category} %{timeAgo}.', ), - similarRecords: s__( + creditCardSimilarRecords: s__( 'AbuseReport|Card matches %{cardMatchesLinkStart}%{count} accounts%{cardMatchesLinkEnd}', ), + phoneNumberSimilarRecords: s__( + 'AbuseReport|Phone matches %{phoneMatchesLinkStart}%{count} accounts%{phoneMatchesLinkEnd}', + ), }; export const REPORTED_CONTENT_I18N = { diff --git a/app/models/users/phone_number_validation.rb b/app/models/users/phone_number_validation.rb index 072b75a1c90..f6521eada40 100644 --- a/app/models/users/phone_number_validation.rb +++ b/app/models/users/phone_number_validation.rb @@ -9,7 +9,7 @@ module Users ignore_column :verification_attempts, remove_with: '16.7', remove_after: '2023-11-17' - belongs_to :user, foreign_key: :user_id + belongs_to :user belongs_to :banned_user, class_name: '::Users::BannedUser', foreign_key: :user_id validates :country, presence: true, length: { maximum: 3 } @@ -26,13 +26,24 @@ module Users presence: true, format: { with: /\A\d+\Z/, - message: -> (object, data) { _('can contain only digits') } + message: ->(_object, _data) { _('can contain only digits') } }, length: { maximum: 12 } validates :telesign_reference_xid, length: { maximum: 255 } - scope :for_user, -> (user_id) { where(user_id: user_id) } + scope :for_user, ->(user_id) { where(user_id: user_id) } + + scope :similar_to, ->(phone_number_validation) do + where( + international_dial_code: phone_number_validation.international_dial_code, + phone_number: phone_number_validation.phone_number + ) + end + + def similar_records + self.class.similar_to(self).includes(:user) + end def self.related_to_banned_user?(international_dial_code, phone_number) joins(:banned_user) diff --git a/app/serializers/admin/abuse_report_details_entity.rb b/app/serializers/admin/abuse_report_details_entity.rb index a654482b989..81a054cb115 100644 --- a/app/serializers/admin/abuse_report_details_entity.rb +++ b/app/serializers/admin/abuse_report_details_entity.rb @@ -44,6 +44,15 @@ module Admin end end + expose :phone_number, if: ->(report) { report.user.phone_number_validation.present? } do + expose :similar_records_count do |report| + report.user.phone_number_validation.similar_records.count + end + expose :phone_matches_link do |report| + phone_match_admin_user_path(report.user) if Gitlab.ee? + end + end + expose :past_closed_reports do |report| AbuseReportEntity.represent(report.past_closed_reports_for_user, only: [:created_at, :category, :report_path]) end diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 46fe6bed05e..649ed00ea22 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -151,6 +151,8 @@ = render_if_exists 'admin/users/credit_card_info', user: @user, link_to_match_page: true + = render_if_exists 'admin/users/phone_info', user: @user, link_to_match_page: true + = render 'shared/custom_attributes', custom_attributes: @user.custom_attributes -# Rendered on desktop only so order of cards can be different on desktop vs mobile |