From 49d509935284c2f07c8f5cb53a31d5787c6ef7ab Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Sat, 14 Feb 2015 13:26:08 -0700 Subject: Avoid duplicate application rows Iterate over authorized applications instead of tokens to avoid multiple rows for the same authorized app. --- app/controllers/profiles_controller.rb | 3 +++ app/views/profiles/applications.html.haml | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index f7584c03411..e3e36505f0b 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -16,6 +16,9 @@ class ProfilesController < ApplicationController def applications @applications = current_user.oauth_applications @authorized_tokens = current_user.oauth_authorized_tokens + @authorized_apps = @authorized_tokens.map do |token| + token.application + end.uniq end def update diff --git a/app/views/profiles/applications.html.haml b/app/views/profiles/applications.html.haml index cb24e4a3dde..4b5817e10bf 100644 --- a/app/views/profiles/applications.html.haml +++ b/app/views/profiles/applications.html.haml @@ -36,12 +36,12 @@ %th Scope %th %tbody - - @authorized_tokens.each do |token| - - application = token.application - %tr{:id => "application_#{application.id}"} - %td= application.name + - @authorized_apps.each do |app| + - token = app.authorized_tokens.order('created_at desc').first + %tr{:id => "application_#{app.id}"} + %td= app.name %td= token.created_at %td= token.scopes - %td= render 'doorkeeper/authorized_applications/delete_form', application: application + %td= render 'doorkeeper/authorized_applications/delete_form', application: app - else %p.light You dont have any authorized applications -- cgit v1.2.1 From 020ec31eb5f09380e8cdcc877ffbdf27b0afb2d7 Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Sat, 14 Feb 2015 20:47:57 -0700 Subject: Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 0bf8de6bd17..74b24168a92 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,6 +53,7 @@ v 7.8.0 (unreleased) - Show assignees in merge request index page (Kelvin Mutuma) - Link head panel titles to relevant root page. - Allow users that signed up via OAuth to set their password in order to use Git over HTTP(S). + - Fix duplicate authorized applications in user profile. v 7.7.2 - Update GitLab Shell to version 2.4.2 that fixes a bug when developers can push to protected branch -- cgit v1.2.1 From 9e0467c38efb1a279b87cf17df5fb1b9b85aa0fe Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Sun, 15 Feb 2015 15:43:18 -0700 Subject: Fix application client count Display the number of unique users with an access token instead of the total number of access tokens per application in the admin area. --- CHANGELOG | 2 +- app/views/admin/applications/index.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 74b24168a92..bdcfe38d102 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,7 +53,7 @@ v 7.8.0 (unreleased) - Show assignees in merge request index page (Kelvin Mutuma) - Link head panel titles to relevant root page. - Allow users that signed up via OAuth to set their password in order to use Git over HTTP(S). - - Fix duplicate authorized applications in user profile. + - Fix duplicate authorized applications in user profile and incorrect application client count in admin area. v 7.7.2 - Update GitLab Shell to version 2.4.2 that fixes a bug when developers can push to protected branch diff --git a/app/views/admin/applications/index.html.haml b/app/views/admin/applications/index.html.haml index f2fed51eaf8..0632888dc82 100644 --- a/app/views/admin/applications/index.html.haml +++ b/app/views/admin/applications/index.html.haml @@ -17,6 +17,6 @@ %tr{:id => "application_#{application.id}"} %td= link_to application.name, admin_application_path(application) %td= application.redirect_uri - %td= application.access_tokens.count + %td= application.access_tokens.map { |t| t.resource_owner_id }.uniq.count %td= link_to 'Edit', edit_admin_application_path(application), class: 'btn btn-link' %td= render 'delete_form', application: application -- cgit v1.2.1 From e0f61a59b4e9be1fc2f20320a0400793318b8a9f Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Sun, 15 Feb 2015 20:50:53 -0700 Subject: Use shorter map() syntax --- app/controllers/profiles_controller.rb | 4 +--- app/views/admin/applications/index.html.haml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index e3e36505f0b..a7863aba756 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -16,9 +16,7 @@ class ProfilesController < ApplicationController def applications @applications = current_user.oauth_applications @authorized_tokens = current_user.oauth_authorized_tokens - @authorized_apps = @authorized_tokens.map do |token| - token.application - end.uniq + @authorized_apps = @authorized_tokens.map(&:application).uniq end def update diff --git a/app/views/admin/applications/index.html.haml b/app/views/admin/applications/index.html.haml index 0632888dc82..d550278710e 100644 --- a/app/views/admin/applications/index.html.haml +++ b/app/views/admin/applications/index.html.haml @@ -17,6 +17,6 @@ %tr{:id => "application_#{application.id}"} %td= link_to application.name, admin_application_path(application) %td= application.redirect_uri - %td= application.access_tokens.map { |t| t.resource_owner_id }.uniq.count + %td= application.access_tokens.map(&:resource_owner_id).uniq.count %td= link_to 'Edit', edit_admin_application_path(application), class: 'btn btn-link' %td= render 'delete_form', application: application -- cgit v1.2.1