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
before_action :authenticate_user!
def show
def index
respond_to do |format|
format.all { @user_apps = UserApplicationsPresenter.new current_user }
end

View file

@ -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)

View file

@ -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")

View file

@ -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"

View file

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