From 469521c572642ad113c93fb1763239d07e8dfd44 Mon Sep 17 00:00:00 2001 From: augier Date: Sun, 2 Aug 2015 11:10:31 +0200 Subject: [PATCH] Addin scopes translation and description --- .../user_applications_controller.rb | 2 +- app/presenters/user_applications_presenter.rb | 11 ++++++----- .../_add_remove_applications.haml | 10 ++++++---- .../{show.html.haml => index.html.haml} | 0 .../{show.mobile.haml => index.mobile.haml} | 0 config/locales/diaspora/en.yml | 18 ++++++++++++++++-- config/routes.rb | 2 +- 7 files changed, 30 insertions(+), 13 deletions(-) rename app/views/user_applications/{show.html.haml => index.html.haml} (100%) rename app/views/user_applications/{show.mobile.haml => index.mobile.haml} (100%) diff --git a/app/controllers/user_applications_controller.rb b/app/controllers/user_applications_controller.rb index b85b0f948..35741d02b 100644 --- a/app/controllers/user_applications_controller.rb +++ b/app/controllers/user_applications_controller.rb @@ -1,7 +1,7 @@ class UserApplicationsController < ApplicationController before_action :authenticate_user! - def show + def index respond_to do |format| format.all { @user_apps = UserApplicationsPresenter.new current_user } end diff --git a/app/presenters/user_applications_presenter.rb b/app/presenters/user_applications_presenter.rb index 07f33e470..5a0ad9cfc 100644 --- a/app/presenters/user_applications_presenter.rb +++ b/app/presenters/user_applications_presenter.rb @@ -21,16 +21,17 @@ class UserApplicationsPresenter def app_as_json(application) { - id: find_id(application), - name: application.client_name, - image: application.image_uri, - autorizations: find_scopes(application) + id: find_id(application), + name: application.client_name, + image: application.image_uri, + authorizations: find_scopes(application) } end def find_scopes(application) - Api::OpenidConnect::Authorization.find_by_client_id_and_user( + scopes = Api::OpenidConnect::Authorization.find_by_client_id_and_user( application.client_id, @current_user).scopes + scopes.each_with_object([]){|scope, array| array << scope.name } end def find_id(application) diff --git a/app/views/user_applications/_add_remove_applications.haml b/app/views/user_applications/_add_remove_applications.haml index 0a8fc7888..2a6a1e3f5 100644 --- a/app/views/user_applications/_add_remove_applications.haml +++ b/app/views/user_applications/_add_remove_applications.haml @@ -6,11 +6,13 @@ .col-xs-2.application-img = image_tag app[:image], class: "img-responsive" .col-xs-10 - - if app[:autorizations].count > 0 - %h4="#{app[:name]} #{t("user_applications.show.access")}" + - if app[:authorizations].count > 0 + %h4="#{app[:name]} #{t("user_applications.index.access")}" %ul - - app[:autorizations].each do |autorization| - %li=autorization.name + - app[:authorizations].each do |authorization| + %li + %b= t("user_applications.scopes.#{authorization}.name") + %p= t("user_applications.scopes.#{authorization}.description") - else .well =t("user_applications.show.no_requirement") diff --git a/app/views/user_applications/show.html.haml b/app/views/user_applications/index.html.haml similarity index 100% rename from app/views/user_applications/show.html.haml rename to app/views/user_applications/index.html.haml diff --git a/app/views/user_applications/show.mobile.haml b/app/views/user_applications/index.mobile.haml similarity index 100% rename from app/views/user_applications/show.mobile.haml rename to app/views/user_applications/index.mobile.haml diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 92528ba8e..83b4ebc34 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -1478,11 +1478,25 @@ en: closed: "Closed" user_applications: - show: + index: edit_applications: "Applications" - title: "Your installed applications" + title: "Your authorized applications" access: "is authorized to access to:" no_requirement: "This application requires no autorizations" applications_explanation: "Here are listed the applications to which you autorized the access to your profile informations" no_applications: "You have no authorized application for now" revoke_autorization: "Revoke autorization" + scopes: + openid: + name: "basic profile" + description: "This allows the application to read informations of your basic profile" + extended: + name: "extended profile" + description: "This allows the application to read informations of your extended profile" + read: + name: "read profile, stream and conversations" + description: "This allows the application to read your stream, your conversations and your complete profile" + write: + name: "send post, conversations and likes" + description: "This allows the application to send new posts, start conversations or send a new messages in an existant conversation and send likes" + diff --git a/config/routes.rb b/config/routes.rb index 9a8f841bc..b38cd165c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -255,5 +255,5 @@ Diaspora::Application.routes.draw do end end - resource :user_applications, only: [:show] + get "user_applications", to: "user_applications#index" end