social_stream-oauth2_server 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -6
  3. data/app/assets/images/step_1.png +0 -0
  4. data/app/assets/images/step_2.png +0 -0
  5. data/app/assets/images/step_3.png +0 -0
  6. data/app/assets/javascripts/social_stream/site_client.js +27 -0
  7. data/app/assets/stylesheets/social_stream/oauth2_server/applications/layout/_applications-oauth2server.css.sass +0 -5
  8. data/app/assets/stylesheets/social_stream/oauth2_server/create/layout/_create-oauth2server.css.sass +3 -5
  9. data/app/assets/stylesheets/social_stream/oauth2_server/show/layout/_show-oauth2server.css.sass +8 -6
  10. data/app/controllers/site/clients_controller.rb +17 -41
  11. data/app/decorators/social_stream/base/relation_decorator.rb +2 -0
  12. data/app/decorators/social_stream/base/user_decorator.rb +1 -20
  13. data/app/models/relation/manager.rb +1 -10
  14. data/app/models/site/client.rb +4 -2
  15. data/app/views/site/clients/_destroy.html.erb +11 -0
  16. data/app/views/site/clients/_edit.html.erb +9 -2
  17. data/app/views/site/clients/_edit_step_2.html.erb +6 -6
  18. data/app/views/site/clients/_edit_step_3.html.erb +8 -6
  19. data/app/views/site/clients/_form.html.erb +11 -11
  20. data/app/views/site/clients/_list.html.erb +23 -11
  21. data/app/views/site/clients/edit.html.erb +1 -1
  22. data/app/views/site/clients/index.html.erb +9 -40
  23. data/app/views/site/clients/show.html.erb +66 -68
  24. data/config/locales/en.yml +19 -0
  25. data/config/locales/es.yml +23 -4
  26. data/config/locales/zh.yml +32 -13
  27. data/config/routes.rb +3 -1
  28. data/lib/social_stream/oauth2_server.rb +4 -1
  29. data/lib/social_stream/oauth2_server/ability.rb +1 -1
  30. data/lib/social_stream/oauth2_server/models/user.rb +18 -0
  31. data/lib/social_stream/oauth2_server/version.rb +1 -1
  32. data/social_stream-oauth2_server.gemspec +1 -1
  33. data/spec/controllers/site_clients_controller_authorization_spec.rb +7 -0
  34. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67ad473cb098893e70019be985fb955ed25d9be8
4
- data.tar.gz: 42c14dc76f1727f9391b7bbe552d20ccc7132275
3
+ metadata.gz: 0f974cd2ca225c2e81f96ebfe5705847aa8f79db
4
+ data.tar.gz: 767419bbe1194902609edfdea7d5502968c4882c
5
5
  SHA512:
6
- metadata.gz: ac541dd775db872b3dae6ae7841ac28310821d6be214062f81070c66a7650c28853ed9d86f60375141bbf12dd1d8eaa19bf9f679edbbbab414e02823641686bd
7
- data.tar.gz: bc4534f5b7024c56255601f6bbe37f990f4dc63e19b23d7e9567849565631af6e2082456b83e9a45ed2c0a295a2f2f8b04482607f1cf3c9908f4e395ddf9fac8
6
+ metadata.gz: 047a94b500d2e5b14fde61acc72d5978babf0d9fa5c67c6c7cb2a856449cb9686dead638ee8a86ec0911bfd14567bc2e790ef7a623ee7c87e3c464c15ed11ec9
7
+ data.tar.gz: 57c1b9cf96589fcf8fe39790460e8ac712b65e194af414d69a6b0e2ed24455ee48201e12743b8a26a86b6f2da222180b91ee27a2006726431e880cf0e3100b4b
data/Rakefile CHANGED
@@ -3,12 +3,7 @@ require 'bundler/gem_tasks'
3
3
 
4
4
  require 'rdoc/task'
5
5
 
6
- require 'rspec/core'
7
- require 'rspec/core/rake_task'
8
-
9
- RSpec::Core::RakeTask.new(:spec)
10
-
11
- task :default => :spec
6
+ task :default => :rdoc
12
7
 
13
8
  Rake::RDocTask.new(:rdoc) do |rdoc|
14
9
  rdoc.rdoc_dir = 'rdoc'
Binary file
Binary file
@@ -1,4 +1,5 @@
1
1
  //= require social_stream/callback
2
+ //= require social_stream/flash
2
3
 
3
4
  SocialStream.SiteClient = (function(SS, $, undefined) {
4
5
  var callback = new SS.Callback();
@@ -7,8 +8,34 @@ SocialStream.SiteClient = (function(SS, $, undefined) {
7
8
  $('.new_site_client-modal-link').attr('href', '#new_site_client-modal');
8
9
  };
9
10
 
11
+ var initRefreshButton = function() {
12
+ $('form.site-client-secret').submit(sendSecretRefresh);
13
+ };
14
+
15
+ var sendSecretRefresh = function(e) {
16
+ var form = $(e.target);
17
+
18
+ e.preventDefault();
19
+
20
+ $.ajax({
21
+ url: form.attr('action'),
22
+ method: form.attr('method'),
23
+ dataType: 'json',
24
+ success: function(data) {
25
+ SS.Flash.success(I18n.t('site.client.oauth.secret.refreshed'));
26
+
27
+ $('span.site-client-secret').html(data.secret).effect('highlight', {}, 3000);
28
+ },
29
+ error: function(jqXHR, textStatus) {
30
+ SS.Flash.error(textStatus);
31
+ }
32
+ });
33
+ };
34
+
10
35
  callback.register('index', initNewModal);
11
36
 
37
+ callback.register('show', initRefreshButton);
38
+
12
39
  return callback.extend({
13
40
  });
14
41
 
@@ -48,8 +48,3 @@
48
48
  input
49
49
  &[type="file"]
50
50
  line-height: 0px
51
-
52
-
53
- .site_clients_list
54
- ul
55
- li
@@ -29,9 +29,7 @@
29
29
  .description
30
30
  textarea
31
31
  height: 60px
32
- input
33
- &[type="submit"]
34
- @include btn-primary
35
- @include border-radius (5px)
36
-
32
+ .next-step
33
+ @include btn-secundary
34
+ float: right
37
35
 
@@ -37,12 +37,14 @@
37
37
  padding: 0 2.5%
38
38
  margin-bottom: 30px
39
39
  display: inline-block
40
- h1
41
- @include clearfix
42
- margin-bottom: 4px
43
- margin-left: -2.5%
44
- a
45
- font-size: 13px
40
+ header
41
+ margin-top: -37px
42
+ h4
43
+ @include clearfix
44
+ margin-bottom: 4px
45
+ margin-left: -2.5%
46
+ a
47
+ font-size: 13px
46
48
  .soften
47
49
  margin-bottom: 0px
48
50
  .content
@@ -1,60 +1,36 @@
1
1
  class Site::ClientsController < ApplicationController
2
- before_filter :authenticate_user!
2
+ include SocialStream::Controllers::Subjects
3
+ include SocialStream::Controllers::Authorship
3
4
 
4
- before_filter :set_author_ids, only: [ :new, :create, :update ]
5
+ before_filter :authenticate_user!
5
6
 
6
7
  load_and_authorize_resource
7
8
 
8
- def index
9
- @clients = current_subject.managed_site_clients
10
- end
11
-
12
9
  def create
13
- @client = Site::Client.new params[:site_client]
14
-
15
- if @client.save
16
- respond_to do |format|
17
- format.html {
18
- redirect_to edit_site_client_path(@client, step: 2)
19
- }
20
- end
21
- else
22
- respond_to do |format|
23
- format.html { render :new }
24
- end
10
+ create! do |success, error|
11
+ success.html {
12
+ redirect_to polymorphic_path(resource, action: :edit, step: 2)
13
+ }
14
+ error.html { render :new }
25
15
  end
26
16
  end
27
17
 
28
- def edit
29
- @client = Site::Client.find params[:id]
30
- end
18
+ # Refresh the site client token
19
+ def update_secret
20
+ resource.refresh_secret!
31
21
 
32
- def update
33
- @client = Site::Client.find params[:id]
34
-
35
- if @client.update_attributes params[:client]
36
- respond_to do |format|
37
- format.html { redirect_to @client }
38
- end
39
- else
40
- respond_to do |format|
41
- format.html { render :edit }
42
- end
22
+ respond_to do |format|
23
+ format.json { render json: { secret: resource.secret } }
43
24
  end
44
25
  end
45
26
 
46
27
  def destroy
47
- @client.destroy
48
-
49
- redirect_to home_path
28
+ destroy! { :home }
50
29
  end
51
30
 
52
- private
31
+ protected
53
32
 
54
- def set_author_ids
55
- params[:site_client] ||= HashWithIndifferentAccess.new
56
- params[:site_client][:author_id] = current_subject.actor_id
57
- params[:site_client][:user_author_id] = current_user.actor_id
58
- params[:site_client][:owner_id] = current_subject.actor_id
33
+ def collection
34
+ current_subject.managed_site_clients
59
35
  end
60
36
  end
@@ -0,0 +1,2 @@
1
+ # FIXME: dirty hack ahead!
2
+ Relation::Positive << "manager"
@@ -1,20 +1 @@
1
- User.class_eval do
2
- include SocialStream::Oauth2Server::Models::User
3
-
4
- def as_json_with_client options = {}
5
- hash = as_json_without_client options
6
-
7
- if options[:client] && !options[:client].is_a?(User)
8
- hash['roles'] = options[:client].contact_to!(self).relations.map{ |r|
9
- {
10
- id: r.id,
11
- name: r.name
12
- }
13
- }
14
- end
15
-
16
- hash
17
- end
18
-
19
- alias_method_chain :as_json, :client
20
- end
1
+ User.send :include, SocialStream::Oauth2Server::Models::User
@@ -1,19 +1,10 @@
1
1
  # Owner of client sites
2
2
  class Relation::Manager < Relation::Single
3
- PERMISSIONS =
4
- [
5
- [ 'manage', nil ],
6
- [ 'manage', 'relation/custom' ],
7
- [ 'manage', 'contact' ]
8
- ]
3
+ PERMISSIONS = SocialStream.available_permissions['site/client']
9
4
 
10
5
  class << self
11
6
  def create_activity?
12
7
  false
13
8
  end
14
9
  end
15
-
16
- def available_permissions
17
- Permission.instances PERMISSIONS
18
- end
19
10
  end
@@ -23,8 +23,10 @@ class Site::Client < Site
23
23
  end
24
24
  end
25
25
 
26
- def to_param
27
- id
26
+ # Generate a new OAuth secret for this site client
27
+ def refresh_secret!
28
+ set_secret
29
+ save!
28
30
  end
29
31
 
30
32
  private
@@ -0,0 +1,11 @@
1
+ <div id="destroy_site_client" class="accordion-group">
2
+ <header class="accordion-heading">
3
+ <h5>
4
+ <%= link_to t("site.client.destroy.title"), "javascript:void(0);", class: 'accordion-toggle', "data-toggle" => 'collapse', "data-parent" => "#site_client-accordion", "data-target" => "#destroy_site_client-content" %>
5
+ </h5>
6
+ </header>
7
+
8
+ <div class="content collapse" id="destroy_site_client-content">
9
+ <%= link_to t("site.client.destroy.link"), resource, confirm: t("site.client.destroy.confirm"), method: :delete %>
10
+ </div>
11
+ </div>
@@ -1,6 +1,13 @@
1
- <%= render partial: 'form' %>
1
+ <section class="edit_form">
2
+ <%= render partial: 'form' %>
3
+ </section>
2
4
 
3
5
  <section class="site_client_roles">
4
6
  <%= render partial: 'relation/customs/index',
5
- locals: { subject: @client } %>
7
+ locals: { subject: resource } %>
8
+ </section>
9
+
10
+ <section class="delete">
11
+ <%= render partial: 'destroy' %>
6
12
  </section>
13
+
@@ -1,11 +1,11 @@
1
1
  <%= image_tag 'step_2.png' %>
2
2
 
3
- <section class="new_app">
4
- <h1>Set the application's logo</h1>
3
+ <section class="create_logo_app">
4
+ <h4>Set the application's logo</h4>
5
5
 
6
- <%= render partial: 'avatars/form',
7
- object: @client,
8
- as: :avatarable %>
6
+ <%= render partial: 'avatars/form',
7
+ object: resource,
8
+ as: :avatarable %>
9
9
 
10
- <%= link_to "Next", edit_site_client_path(@client, step: 3) %>
10
+ <%= link_to "Next", polymorphic_path(resource, action: 'edit', step: 3), class: "next-step" %>
11
11
  </section>
@@ -1,10 +1,12 @@
1
1
  <%= image_tag 'step_3.png' %>
2
2
 
3
- <h1>Manage roles and permissions</h1>
3
+ <section class="new_app">
4
+ <h4>Manage roles and permissions</h4>
4
5
 
5
- <section class="site_client_roles">
6
- <%= render partial: 'relation/customs/index',
7
- locals: { subject: @client } %>
8
- </section>
6
+ <section class="site_client_roles">
7
+ <%= render partial: 'relation/customs/index',
8
+ locals: { subject: resource } %>
9
+ </section>
9
10
 
10
- <%= link_to 'Finish', @client %>
11
+ <%= link_to 'Finish', resource, class: "next-step" %>
12
+ </section>
@@ -1,4 +1,4 @@
1
- <%= form_for(@client || Site::Client.new) do |f| %>
1
+ <%= form_for(begin; resource; rescue ActiveRecord::RecordNotFound; end || resource_class.new) do |f| %>
2
2
 
3
3
  <% if f.object.errors.any? %>
4
4
  <div id="error_explanation" class="alert alert-error">
@@ -14,26 +14,26 @@
14
14
  <% end %>
15
15
 
16
16
  <section id="site_client_form">
17
- <section class="name">
17
+ <div class="name">
18
18
  <%= f.label :name %>
19
19
  <%= f.text_field :name %>
20
- </section>
20
+ </div>
21
21
 
22
- <section class="description">
22
+ <div class="description">
23
23
  <%= f.label :description %>
24
24
  <%= f.text_area :description %>
25
- </section>
25
+ </div>
26
26
 
27
- <section class="url">
27
+ <div class="url">
28
28
  <%= f.label :url %>
29
29
  <%= f.text_area :url %>
30
- </section>
30
+ </div>
31
31
 
32
- <section class="callback_url">
32
+ <div class="callback_url">
33
33
  <%= f.label :callback_url %>
34
34
  <%= f.text_area :callback_url %>
35
- </section>
36
-
37
- <%= f.submit %>
35
+ </div>
38
36
  </section>
37
+ <%= f.submit :class => "next-step" %>
38
+
39
39
  <% end %>
@@ -2,19 +2,31 @@
2
2
  <ul>
3
3
  <% list.each do |client| %>
4
4
  <li>
5
- <%= image_tag client.logo.url(:small), style: "width: 40px; height: 40px;" %>
5
+ <%= link_to client do %>
6
+ <%= image_tag client.logo.url(:small) %>
7
+ <% end %>
6
8
 
7
- <div class="name">
8
- <%= link_to client.name, client %>
9
+ <div class="data">
10
+ <div class="name">
11
+ <%= link_to client.name, client %>
12
+ </div>
13
+ <div class="url">
14
+ <%= link_to client.url, client.url, target: '_blank' %>
15
+ </div>
9
16
  </div>
10
- <div class="url">
11
- <%= link_to client.url, client.url, target: '_blank' %>
12
- </div>
13
- <div class="users">
14
- <span>
15
- 5
16
- </span>
17
- users
17
+ <div class="team">
18
+ <div class="users">
19
+ <span>
20
+ 5
21
+ </span>
22
+ users
23
+ </div>
24
+ <div class="auth">
25
+ <span>
26
+ 15
27
+ </span>
28
+ authorized
29
+ </div>
18
30
  </div>
19
31
  <hr class="soften">
20
32
  </li>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <%= render partial: 'toolbar/home' %>
4
4
 
5
- <section class="edit_site_client" id="edit_<%= dom_id @client %>">
5
+ <section class="edit_site_client" id="edit_<%= dom_id resource %>">
6
6
  <% if params[:step].present? %>
7
7
  <%= render partial: "edit_step_#{ params[:step] }" %>
8
8
  <% else %>
@@ -5,55 +5,24 @@
5
5
  <section class="site_clients">
6
6
  <header>
7
7
  <h3>
8
- <%= link_to t('site.client.new.link'), new_site_client_path, class: "new_site_client-modal-link", 'data-toggle' => 'modal' %>
8
+ <%= link_to t('site.client.new.link'), polymorphic_path(resource_class.new, action: 'new'), class: "new_site_client-modal-link", 'data-toggle' => 'modal' %>
9
9
 
10
- <%= t 'site.client.added' %>
10
+ Applications
11
11
  </h3>
12
12
  </header>
13
13
  <div class="tabbable"> <!-- Only required for left/right tabs -->
14
14
  <ul class="nav nav-tabs">
15
- <li class="active"><a href="#tab1" data-toggle="tab">Mine</a></li>
16
- <li><a href="#tab2" data-toggle="tab">Others</a></li>
17
- </ul>
18
- <div class="search-nav hidden-phone">
19
- <%= form_tag search_path, method: 'get', class: "navbar-search pull-left" do %>
20
- <%= text_field_tag :q, nil, autocomplete: :off, class: 'search-query input-small', placeholder: t('search.name'), "data-min_query" => SocialStream::Search::MIN_QUERY %>
21
- <% end %>
22
- <%= javascript_tag do %>
23
- $(function() {
24
- SocialStream.SearchHeader.show();
25
- });
26
- <% end %>
27
- <div class="mat">
28
- <%= render partial: 'layouts/loading' %>
29
-
30
- <div class="query_too_short">
31
- <%= t 'search.at_least', count: SocialStream::Search::MIN_QUERY %>
32
- </div>
33
-
34
- <div class="no_results">
35
- <%= t 'search.nothing' %>
36
- </div>
37
-
38
- <div class="results">
39
- </div>
40
- </div>
41
- </div>
42
-
15
+ <li class="active"><a href="#tab1" data-toggle="tab">Managing</a></li>
16
+ </ul>
17
+ </div>
43
18
 
44
- <div class="tab-content">
45
- <div class="tab-pane active" id="tab1">
46
- <%= render partial: 'list',
47
- object: @clients %>
48
- </div>
49
19
 
50
- <div class="tab-pane" id="tab2">
51
- </div>
20
+ <div class="tab-content">
21
+ <div class="tab-pane active" id="tab1">
22
+ <%= render partial: 'list',
23
+ object: collection %>
52
24
  </div>
53
25
  </div>
54
-
55
26
  <%= render partial: 'new.modal' %>
56
-
57
- <hr class="soften">
58
27
  </section>
59
28
  </section>
@@ -1,14 +1,15 @@
1
1
  <section id="site_client">
2
2
  <%= render partial: 'toolbar/home' %>
3
3
 
4
- <section class="site_client" id="<%= dom_id @client %>">
4
+ <section class="site_client" id="<%= dom_id resource %>">
5
5
  <header>
6
- <h1>
7
- <%= @client.name %>
8
- <a class="go-more" href="#">
9
- ir a tus demás aplicaciones
10
- </a>
11
- </h1>
6
+ <h4>
7
+ <%= resource.name %>
8
+
9
+ <% if can?(:update, resource) %>
10
+ <%= link_to t('site.client.button.edit'), polymorphic_path(resource, action: 'edit'), class: "edit" %>
11
+ <% end %>
12
+ </h4>
12
13
 
13
14
  <%= image_tag('logos/app-default.png', class: "logo-app pull-right") %>
14
15
 
@@ -20,53 +21,63 @@
20
21
  <%= Site::Client.human_attribute_name :description %>
21
22
  </h4>
22
23
  <div class="result">
23
- <%= @client.description%>
24
+ <%= resource.description%>
24
25
  </div>
25
26
 
26
27
  <h4>
27
28
  <%= Site::Client.human_attribute_name :url %>
28
29
  </h4>
29
30
  <div class="result">
30
- <%= link_to @client.url, @client.url%>
31
+ <%= link_to resource.url, resource.url%>
31
32
  </div>
32
33
 
33
- <% if can? :update, @client %>
34
+ <% if can? :update, resource %>
34
35
  <h4>
35
36
  <%= Site::Client.human_attribute_name :callback_url %>
36
37
  </h4>
37
38
  <div class="result">
38
- <%= @client.callback_url %>
39
+ <%= resource.callback_url %>
39
40
  </div>
40
41
  <% end %>
41
42
  </div>
42
43
 
43
- <% if can? :update, @client %>
44
- <div class="btn-group">
45
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
46
- Credentials
47
- <span class="caret"></span>
48
- </a>
49
- <ul class="dropdown-menu">
50
- <li>
51
- <h6>
52
- <%= Site::Client.human_attribute_name :id %>
53
- </h6>
54
- <p>
55
- <%= @client.id %>
56
- </p>
57
- </li>
58
-
59
- <li class="client-secret">
60
- <h6>
61
- <%= Site::Client.human_attribute_name :secret %>
62
- <a href="#" class="pull-right">refresh</a>
63
- </h6>
64
- <p>
65
- <%= @client.secret %>
66
- </p>
67
- </li>
68
- </ul>
69
- </div>
44
+ <% if can? :update_secret, resource %>
45
+ <div class="accordion" id="accordion2">
46
+ <div class="accordion-group">
47
+ <div class="accordion-heading">
48
+ <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
49
+ <%= t 'site.client.oauth.credentials' %>
50
+ </a>
51
+ </div>
52
+ <div id="collapseOne" class="accordion-body collapse">
53
+ <div class="accordion-inner">
54
+ <div class="content settings_content collapse in">
55
+ <div class="result">
56
+ <div class="client-id">
57
+ <h6>
58
+ <%= Site::Client.human_attribute_name :id %>
59
+ </h6>
60
+ <p>
61
+ <%= resource.id %>
62
+ </p>
63
+ </div>
64
+ <div class="client-secret">
65
+ <h6>
66
+ <%= Site::Client.human_attribute_name :secret %>
67
+ <%= form_tag update_secret_site_client_path(resource, format: :json), class: "site-client-secret" do %>
68
+ <%= submit_tag t('site.client.oauth.secret.refresh'), class: 'pull-right' %>
69
+ <% end %>
70
+ </h6>
71
+ <p>
72
+ <span class="site-client-secret"><%= resource.secret %></span>
73
+ </p>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
70
81
  <% end %>
71
82
  </div>
72
83
  </section>
@@ -74,48 +85,35 @@
74
85
  <div class="tabbable"> <!-- Only required for left/right tabs -->
75
86
  <ul class="nav nav-tabs">
76
87
  <li class="active"><a href="#authorized" data-toggle="tab">Authorized</a></li>
77
- <li><a href="#registered" data-toggle="tab">Registered</a></li>
78
- <li><a href="#stats" data-toggle="tab">Stats</a></li>
88
+ <li><a href="#registered" data-toggle="tab">Users</a></li>
79
89
  </ul>
80
- <div class="search-nav hidden-phone">
81
- <%= form_tag search_path, method: 'get', class: "navbar-search pull-left" do %>
82
- <%= text_field_tag :q, nil, autocomplete: :off, class: 'search-query input-small', placeholder: t('search.name'), "data-min_query" => SocialStream::Search::MIN_QUERY %>
83
- <% end %>
84
- <%= javascript_tag do %>
85
- $(function() {
86
- SocialStream.SearchHeader.show();
87
- });
88
- <% end %>
89
-
90
- <div class="mat">
91
- <%= render partial: 'layouts/loading' %>
92
-
93
- <div class="query_too_short">
94
- <%= t 'search.at_least', count: SocialStream::Search::MIN_QUERY %>
95
- </div>
96
-
97
- <div class="no_results">
98
- <%= t 'search.nothing' %>
99
- </div>
100
-
101
- <div class="results">
102
- </div>
103
- </div>
90
+
91
+ <%= render partial: 'contacts/add_button',
92
+ locals: {
93
+ sender: resource,
94
+ type: [ :user, :group ]
95
+ }
96
+ %>
97
+
98
+ <div class="btn-group" data-toggle="buttons">
99
+ <button type="radio" name="options" id="option1">user</button>
100
+ <button type="radio" name="options" id="option2"">organization</button>
104
101
  </div>
105
102
 
103
+ <%= text_field_tag "contact-filter", "", placeholder: "filter", autocomplete: "off" %>
106
104
 
107
105
  <div class="tab-content">
108
106
  <div class="tab-pane active" id="authorized">
109
107
  <%= render partial: 'contacts/contact',
110
- collection: @client.sent_contacts.first(12) %>
108
+ collection: resource.sent_contacts.first(12) %>
111
109
  </div>
112
110
 
113
111
  <div class="tab-pane" id="registered">
114
112
  </div>
115
-
116
- <div class="tab-pane" id="stats">
117
- </div>
118
113
  </div>
119
114
  </div>
120
115
 
116
+ <%= javascript_tag do %>
117
+ SocialStream.SiteClient.show();
118
+ <% end %>
121
119
  </section>
@@ -33,6 +33,9 @@ en:
33
33
  relation/custom: Manage roles
34
34
  detailed:
35
35
  manage:
36
+ contact:
37
+ negative: They WILL NOT BE ABLE to assign roles to users
38
+ positive: They WILL BE ABLE to assign roles to users
36
39
  nil:
37
40
  positive: They WILL BE ABLE to update the details of the client site
38
41
  negative: They WILL NOT BE ABLE to update the details of the client
@@ -45,11 +48,27 @@ en:
45
48
  public_info: Read your public information
46
49
  relation_admin:
47
50
  name: Site Client Admin
51
+ relation_manager:
52
+ name: Manager
48
53
  site:
49
54
  client:
50
55
  added: Added sites
56
+ button:
57
+ edit: Edit
58
+ contact:
59
+ add: Add
60
+ destroy:
61
+ confirm: Are you sure? This operation cannot be reverted!
62
+ link: Remove the site client and all its data
63
+ title: Destroy site client
64
+ go_to_other: See your other site clients
51
65
  index:
52
66
  title: Client sites
53
67
  new:
54
68
  link: Add site
55
69
  title: Register new client site
70
+ oauth:
71
+ credentials: Credentials
72
+ secret:
73
+ refresh: refresh
74
+ refreshed: OAuth2 client secret regenerated
@@ -15,9 +15,9 @@ es:
15
15
  accept: Accept
16
16
  cancel: Cancel
17
17
  new:
18
- title: Authorize %{client}?
19
18
  permission:
20
19
  title: 'The site %{client} will be able to:'
20
+ title: Authorize %{client}?
21
21
  helpers:
22
22
  submit:
23
23
  site_client:
@@ -28,25 +28,44 @@ es:
28
28
  default:
29
29
  brief:
30
30
  manage:
31
+ contact: Manage authorizations
31
32
  nil: Gestionar el sitio
32
33
  relation/custom: Gestionar los roles
33
- contact: Manage authorizations
34
34
  detailed:
35
35
  manage:
36
+ contact:
37
+ negative: NO PODRÁN asignar roles a usuarios
38
+ positive: PODRÁN asignar roles a usuarios
36
39
  nil:
37
- positive: PODRÁN actualizar los detalles del sitio
38
40
  negative: NO PODRÁN actualizar los detalles del sitio
41
+ positive: PODRÁN actualizar los detalles del sitio
39
42
  relation/custom:
40
- positive: PODRÁN crear, actualizar y borrar los roles del sitio
41
43
  negative: NO PODRÁN crear, actualizar y borrar los roles del sitio
44
+ positive: PODRÁN crear, actualizar y borrar los roles del sitio
42
45
  public_info: Acceder a tu información pública
43
46
  relation_admin:
44
47
  name: Administrador de Sitio
48
+ relation_manager:
49
+ name: Admin
45
50
  site:
46
51
  client:
47
52
  added: Sitios añadidos
53
+ button:
54
+ edit: Editar
55
+ contact:
56
+ add: Add
57
+ destroy:
58
+ confirm: Are you sure? This operation cannot be reverted!
59
+ link: Remove the site client and all its data
60
+ title: Destroy site client
61
+ go_to_other: Ver tus otros sitios
48
62
  index:
49
63
  title: Sitios
50
64
  new:
51
65
  link: Añadir sitio
52
66
  title: Registrar nuevo sitio
67
+ oauth:
68
+ credentials: Credenciales
69
+ secret:
70
+ refresh: regenerar
71
+ refreshed: Token secreto de OAuth2 regenerado
@@ -15,41 +15,60 @@ zh:
15
15
  accept: Accept
16
16
  cancel: Cancel
17
17
  new:
18
- title: Authorize %{client}?
19
18
  permission:
20
19
  title: 'The site %{client} will be able to:'
20
+ title: Authorize %{client}?
21
+ helpers:
22
+ submit:
23
+ site_client:
24
+ create: Next
25
+ update: Save
21
26
  permission:
22
- public_info: Read your public information
23
27
  description:
24
28
  default:
25
29
  brief:
26
30
  manage:
31
+ contact: Manage authorizations
27
32
  nil: Manage the site
28
33
  relation/custom: Manage roles
29
- contact: Manage authorizations
30
34
  detailed:
31
35
  manage:
36
+ contact:
37
+ negative: They WILL NOT BE ABLE to assign roles to users
38
+ positive: They WILL BE ABLE to assign roles to users
32
39
  nil:
33
- positive: They WILL BE ABLE to update the details of the client site
34
40
  negative: They WILL NOT BE ABLE to update the details of the client
35
41
  site
42
+ positive: They WILL BE ABLE to update the details of the client site
36
43
  relation/custom:
37
- positive: They WILL BE ABLE to create, update and delete the roles of
38
- the client site
39
44
  negative: They WILL NOT BE ABLE to create, update and delete the roles
40
45
  of the client site
46
+ positive: They WILL BE ABLE to create, update and delete the roles of
47
+ the client site
48
+ public_info: Read your public information
49
+ relation_admin:
50
+ name: Site Client Admin
51
+ relation_manager:
52
+ name: Manager
41
53
  site:
42
54
  client:
43
55
  added: Added sites
56
+ button:
57
+ edit: Edit
58
+ contact:
59
+ add: Add
60
+ destroy:
61
+ confirm: Are you sure? This operation cannot be reverted!
62
+ link: Remove the site client and all its data
63
+ title: Destroy site client
64
+ go_to_other: See your other site clients
44
65
  index:
45
66
  title: Client sites
46
67
  new:
47
68
  link: Add site
48
69
  title: Register new client site
49
- helpers:
50
- submit:
51
- site_client:
52
- create: Next
53
- update: Save
54
- relation_admin:
55
- name: Site Client Admin
70
+ oauth:
71
+ credentials: Credentials
72
+ secret:
73
+ refresh: refresh
74
+ refreshed: OAuth2 client secret regenerated
@@ -5,6 +5,8 @@ Rails.application.routes.draw do
5
5
  resources :authorizations, only: :create
6
6
 
7
7
  namespace "site" do
8
- resources :clients
8
+ resources :clients do
9
+ post :update_secret, on: :member
10
+ end
9
11
  end
10
12
  end
@@ -17,11 +17,14 @@ module SocialStream
17
17
  autoload :TokenEndpoint, 'social_stream/oauth2_server/token_endpoint'
18
18
  end
19
19
 
20
+ # Include site/client in routes
21
+ SocialStream.routed_subjects << :"site/client"
22
+
20
23
  # Define default custom relations for Site::Client
21
24
  SocialStream.custom_relations['site/client'] = {}
22
25
 
23
26
  # Relations that appear in the Site::Client list
24
- SocialStream.list_relations['site/client'] = [ :manager ]
27
+ SocialStream.system_relations['site/client'] = [ :manager ]
25
28
 
26
29
  SocialStream.available_permissions['site/client'] = [
27
30
  [ 'manage', nil ],
@@ -11,7 +11,7 @@ module SocialStream
11
11
  c.author_id == subject.actor_id
12
12
  end
13
13
 
14
- can [:update, :destroy], Site::Client do |c|
14
+ can [:update, :update_secret, :destroy], Site::Client do |c|
15
15
  c.allow? subject, 'manage'
16
16
  end
17
17
 
@@ -16,6 +16,8 @@ module SocialStream
16
16
 
17
17
  has_many :refresh_tokens,
18
18
  class_name: 'Oauth2Token::RefreshToken'
19
+
20
+ alias_method_chain :as_json, :client
19
21
  end
20
22
 
21
23
  # Is {#client} authorized by this {User}
@@ -29,6 +31,22 @@ module SocialStream
29
31
  contact_to!(client).relation_ids += [ Relation::Auth.instance.id ]
30
32
  end
31
33
  end
34
+
35
+ # Include application role information in the json
36
+ def as_json_with_client options = {}
37
+ hash = as_json_without_client options
38
+
39
+ if options[:client] && !options[:client].is_a?(User)
40
+ hash['roles'] = options[:client].contact_to!(self).relations.map{ |r|
41
+ {
42
+ id: r.id,
43
+ name: r.name
44
+ }
45
+ }
46
+ end
47
+
48
+ hash
49
+ end
32
50
  end
33
51
  end
34
52
  end
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Oauth2Server
3
- VERSION = "2.1.1".freeze
3
+ VERSION = "2.2.0".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 2.1.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 2.2.0')
16
16
  s.add_runtime_dependency('rack-oauth2', '~> 1.0.0')
17
17
 
18
18
  s.add_development_dependency('rspec-rails', '~> 2.8.0')
@@ -38,6 +38,13 @@ describe Site::ClientsController do
38
38
  sign_in @user
39
39
  end
40
40
 
41
+ it "should render index" do
42
+ @client = Factory(:"site/client", author: @user.actor )
43
+ get :index
44
+
45
+ response.should be_success
46
+ end
47
+
41
48
  it "should render client" do
42
49
  @client = Factory(:"site/client", author: @user.actor )
43
50
  get :show, :id => @client.to_param
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-oauth2_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Tapiador
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-31 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: social_stream-base
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 2.1.0
20
+ version: 2.2.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: 2.1.0
27
+ version: 2.2.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rack-oauth2
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +70,7 @@ files:
70
70
  - app/assets/images/logos/small/site.png
71
71
  - app/assets/images/step_1.png
72
72
  - app/assets/images/step_2.png
73
+ - app/assets/images/step_3.png
73
74
  - app/assets/javascripts/social_stream-oauth2_server.js
74
75
  - app/assets/javascripts/social_stream/site_client.js
75
76
  - app/assets/stylesheets/social_stream-oauth2_server.css.sass
@@ -93,6 +94,7 @@ files:
93
94
  - app/controllers/authorizations_controller.rb
94
95
  - app/controllers/site/clients_controller.rb
95
96
  - app/decorators/social_stream/base/actor_decorator.rb
97
+ - app/decorators/social_stream/base/relation_decorator.rb
96
98
  - app/decorators/social_stream/base/user_decorator.rb
97
99
  - app/decorators/social_stream/base/users_controller_decorator.rb
98
100
  - app/helpers/site_client_helper.rb
@@ -108,6 +110,7 @@ files:
108
110
  - app/views/authorizations/error.html.erb
109
111
  - app/views/authorizations/new.html.erb
110
112
  - app/views/site/clients/_avatar.html.erb
113
+ - app/views/site/clients/_destroy.html.erb
111
114
  - app/views/site/clients/_edit.html.erb
112
115
  - app/views/site/clients/_edit_step_2.html.erb
113
116
  - app/views/site/clients/_edit_step_3.html.erb
@@ -164,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
167
  version: '0'
165
168
  requirements: []
166
169
  rubyforge_project:
167
- rubygems_version: 2.0.0
170
+ rubygems_version: 2.0.6
168
171
  signing_key:
169
172
  specification_version: 4
170
173
  summary: OAuth2 server support for Social Stream, the framework for building social