Addin scopes translation and description

This commit is contained in:
augier 2015-08-02 11:10:31 +02:00 committed by theworldbright
parent 3734e074a6
commit 469521c572
7 changed files with 30 additions and 13 deletions

View file

@ -1,7 +1,7 @@
class UserApplicationsController < ApplicationController class UserApplicationsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def show def index
respond_to do |format| respond_to do |format|
format.all { @user_apps = UserApplicationsPresenter.new current_user } format.all { @user_apps = UserApplicationsPresenter.new current_user }
end end

View file

@ -24,13 +24,14 @@ class UserApplicationsPresenter
id: find_id(application), id: find_id(application),
name: application.client_name, name: application.client_name,
image: application.image_uri, image: application.image_uri,
autorizations: find_scopes(application) authorizations: find_scopes(application)
} }
end end
def find_scopes(application) 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 application.client_id, @current_user).scopes
scopes.each_with_object([]){|scope, array| array << scope.name }
end end
def find_id(application) def find_id(application)

View file

@ -6,11 +6,13 @@
.col-xs-2.application-img .col-xs-2.application-img
= image_tag app[:image], class: "img-responsive" = image_tag app[:image], class: "img-responsive"
.col-xs-10 .col-xs-10
- if app[:autorizations].count > 0 - if app[:authorizations].count > 0
%h4="#{app[:name]} #{t("user_applications.show.access")}" %h4="#{app[:name]} #{t("user_applications.index.access")}"
%ul %ul
- app[:autorizations].each do |autorization| - app[:authorizations].each do |authorization|
%li=autorization.name %li
%b= t("user_applications.scopes.#{authorization}.name")
%p= t("user_applications.scopes.#{authorization}.description")
- else - else
.well .well
=t("user_applications.show.no_requirement") =t("user_applications.show.no_requirement")

View file

@ -1478,11 +1478,25 @@ en:
closed: "Closed" closed: "Closed"
user_applications: user_applications:
show: index:
edit_applications: "Applications" edit_applications: "Applications"
title: "Your installed applications" title: "Your authorized applications"
access: "is authorized to access to:" access: "is authorized to access to:"
no_requirement: "This application requires no autorizations" no_requirement: "This application requires no autorizations"
applications_explanation: "Here are listed the applications to which you autorized the access to your profile informations" 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" no_applications: "You have no authorized application for now"
revoke_autorization: "Revoke autorization" 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"

View file

@ -255,5 +255,5 @@ Diaspora::Application.routes.draw do
end end
end end
resource :user_applications, only: [:show] get "user_applications", to: "user_applications#index"
end end