panda_pal 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a4301bb60a4ba38f0341681c27b4e442dcfe4fb
4
- data.tar.gz: 725712ae4689fde81d974a72604bab8a55c02e38
3
+ metadata.gz: adf2baeea79a4d933e487e5a6bad74e1ad7ac09a
4
+ data.tar.gz: 9a1635bb6691fe621819b7b15a0d596d179e3dba
5
5
  SHA512:
6
- metadata.gz: aecc8adfa67900caa78079a7df007fb24befc29036e1dadb6c11738d584f781a5cc92a1cbd8fef2aaa64f07774233111533165382111aea8e15b6cf7816b4985
7
- data.tar.gz: b28cdd4846a21ef177f1edc7f4ed258596e1906d0c5cdf5d4b67d7175bd2622c87fb80436a4d384ed90050657149d452a2a763a8d888d9ccbc172e4fd0f367ab
6
+ metadata.gz: 3f2965242f0181d7929636012adcdaabb7a243b6dba145237b70b79b1972c268b49ef907908a8bc923f911cb9541fe2fdf01d271f3538845bf3819216ef37e8b
7
+ data.tar.gz: fe6a037ec8143bc4bf7ce9588c9a8a5d8e8e213fe48f490c2ea05eccf4a1517a56868cb7349111721a0a052805ef52c23b081b5c7ef81b335c9694a499aba34d
@@ -1,5 +1,9 @@
1
1
  module PandaPal
2
2
  class Session < ActiveRecord::Base
3
+ belongs_to :panda_pal_organization
4
+
5
+ validates :panda_pal_organization_id, presence: true
6
+
3
7
  after_initialize do
4
8
  self.session_key ||= SecureRandom.urlsafe_base64(60)
5
9
  end
@@ -0,0 +1,6 @@
1
+ class AddPandaPalOrganizationToSession < ActiveRecord::Migration
2
+ def change
3
+ add_column :panda_pal_sessions, :panda_pal_organization_id, :integer
4
+ add_index :panda_pal_sessions, :panda_pal_organization_id
5
+ end
6
+ end
@@ -5,12 +5,12 @@ module PandaPal::Helpers::ControllerHelper
5
5
 
6
6
  def current_session
7
7
  @current_session ||= PandaPal::Session.find_by(session_key: session_key) if session_key
8
- @current_session ||= PandaPal::Session.new
8
+ @current_session ||= PandaPal::Session.new(panda_pal_organization_id: current_organization.id)
9
9
  end
10
10
 
11
11
  def current_organization
12
12
  @organization ||= PandaPal::Organization.find_by!(key: organization_key) if organization_key
13
- @organization ||= PandaPal::Organization.find_by(id: params[:organization_id]) if params[:organization_id]
13
+ @organization ||= PandaPal::Organization.find_by(id: organization_id) if organization_id
14
14
  @organization ||= PandaPal::Organization.find_by_name(Apartment::Tenant.current)
15
15
  end
16
16
 
@@ -42,7 +42,16 @@ module PandaPal::Helpers::ControllerHelper
42
42
  end
43
43
 
44
44
  def forbid_access_if_lacking_session
45
- render text: 'You should do an LTI Tool Launch.', status: :unauthorized unless current_session.persisted?
45
+ render text: 'You should do an LTI Tool Launch.', status: :unauthorized unless valid_session?
46
+ end
47
+
48
+ def valid_session?
49
+ [
50
+ current_session.persisted?,
51
+ current_organization,
52
+ current_session.panda_pal_organization_id == current_organization.id,
53
+ Apartment::Tenant.current == current_organization.name
54
+ ].all?
46
55
  end
47
56
 
48
57
  private
@@ -50,6 +59,10 @@ module PandaPal::Helpers::ControllerHelper
50
59
  params[:oauth_consumer_key] || current_session_data[:organization_key] || session[:organization_key]
51
60
  end
52
61
 
62
+ def organization_id
63
+ params[:organization_id]
64
+ end
65
+
53
66
  def session_key
54
67
  params[:session_key] || session_key_header || flash[:session_key] || session[:session_key]
55
68
  end
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_pal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Young
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -163,6 +163,7 @@ files:
163
163
  - db/migrate/20160412205931_create_panda_pal_organizations.rb
164
164
  - db/migrate/20160413132229_create_delayed_jobs.rb
165
165
  - db/migrate/20160413135653_create_panda_pal_sessions.rb
166
+ - db/migrate/20160425130344_add_panda_pal_organization_to_session.rb
166
167
  - lib/panda_pal.rb
167
168
  - lib/panda_pal/engine.rb
168
169
  - lib/panda_pal/helpers.rb
@@ -241,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
242
  version: '0'
242
243
  requirements: []
243
244
  rubyforge_project:
244
- rubygems_version: 2.5.1
245
+ rubygems_version: 2.4.3
245
246
  signing_key:
246
247
  specification_version: 4
247
248
  summary: LTI mountable engine
@@ -294,3 +295,4 @@ test_files:
294
295
  - spec/models/panda_pal/session_spec.rb
295
296
  - spec/rails_helper.rb
296
297
  - spec/spec_helper.rb
298
+ has_rdoc: