Add applications information page
This commit is contained in:
parent
65c40f236e
commit
308170f691
8 changed files with 97 additions and 0 deletions
9
app/controllers/user_applications_controller.rb
Normal file
9
app/controllers/user_applications_controller.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class UserApplicationsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.all { @user_apps = UserApplicationsPresenter.new current_user }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -19,6 +19,10 @@ module Api
|
|||
self.client_secret = SecureRandom.hex(32)
|
||||
end
|
||||
|
||||
def image_uri
|
||||
self.logo_uri ? self.logo_uri : "branding/logos/asterisk.png"
|
||||
end
|
||||
|
||||
class << self
|
||||
def available_response_types
|
||||
["id_token", "id_token token", "code"]
|
||||
|
|
|
|||
34
app/presenters/user_applications_presenter.rb
Normal file
34
app/presenters/user_applications_presenter.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class UserApplicationsPresenter
|
||||
def initialize(user)
|
||||
@current_user = user
|
||||
end
|
||||
|
||||
def user_applications
|
||||
@applications ||= @current_user.o_auth_applications.each_with_object([]) do |app, array|
|
||||
array << app_as_json(app)
|
||||
end
|
||||
end
|
||||
|
||||
def applications_count
|
||||
user_applications.size
|
||||
end
|
||||
|
||||
def applications?
|
||||
applications_count > 0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def app_as_json(application)
|
||||
{
|
||||
name: application.client_name,
|
||||
image: application.image_uri,
|
||||
autorizations: find_scopes(application)
|
||||
}
|
||||
end
|
||||
|
||||
def find_scopes(application)
|
||||
Api::OpenidConnect::Authorization.find_by_client_id_and_user(
|
||||
application.client_id, @current_user).scopes
|
||||
end
|
||||
end
|
||||
|
|
@ -6,3 +6,4 @@
|
|||
%li{class: current_page?(edit_user_path) && "active"}= link_to t("account"), edit_user_path
|
||||
%li{class: current_page?(privacy_settings_path) && "active"}= link_to t("privacy"), privacy_settings_path
|
||||
%li{class: current_page?(services_path) && "active"}= link_to t("_services"), services_path
|
||||
%li{class: current_page?(user_applications_path) && 'active'}= link_to t("_applications"), user_applications_path
|
||||
|
|
|
|||
21
app/views/user_applications/_add_remove_applications.haml
Normal file
21
app/views/user_applications/_add_remove_applications.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
- if @user_apps.applications?
|
||||
%ul.list-group
|
||||
- @user_apps.user_applications.each do |app|
|
||||
%li.list-group-item
|
||||
.row
|
||||
.col-xs-2
|
||||
= image_tag app[:image], class: "img-responsive"
|
||||
.col-xs-10
|
||||
- if app[:autorizations].count > 0
|
||||
%h4="#{app[:name]} #{t("user_applications.show.access")}"
|
||||
%ul
|
||||
- app[:autorizations].each do |autorization|
|
||||
%li=autorization.name
|
||||
- else
|
||||
.well
|
||||
=t("user_applications.show.no_requirement")
|
||||
|
||||
- else
|
||||
.well
|
||||
%h4
|
||||
= t("user_applications.show.no_applications")
|
||||
17
app/views/user_applications/show.html.haml
Normal file
17
app/views/user_applications/show.html.haml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
- content_for :page_title do
|
||||
= t(".edit_applications")
|
||||
|
||||
.container-fluid
|
||||
= render "shared/settings_nav"
|
||||
.container-fluid
|
||||
.row
|
||||
.col-lg-8.col-lg-offset-2
|
||||
%h3= t(".title")
|
||||
%p.visible-sm-block.visible-xs-block
|
||||
= t(".applications_explanation")
|
||||
.row
|
||||
.col-md-7
|
||||
= render "add_remove_applications"
|
||||
.col-md-5
|
||||
%p.hidden-sm.hidden-xs
|
||||
= t(".applications_explanation")
|
||||
|
|
@ -1476,3 +1476,12 @@ en:
|
|||
disabled: "Not available"
|
||||
open: "Open"
|
||||
closed: "Closed"
|
||||
|
||||
user_applications:
|
||||
show:
|
||||
edit_applications: "Applications"
|
||||
title: "Your installed applications"
|
||||
no_applications: "You have no authorized application for now"
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -254,4 +254,6 @@ Diaspora::Application.routes.draw do
|
|||
get "user_info", to: "user_info#show"
|
||||
end
|
||||
end
|
||||
|
||||
resource :user_applications, only: [:show]
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue