openstax_accounts 9.3.0 → 9.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0afe5b4c7d13abc030803addf862691d260ea3036361a2043d8f85bf88fa7fb
4
- data.tar.gz: 24502a41f6cb02271869bdff9869ed3f8efedbe1b393227193746ae6c5d8fc0c
3
+ metadata.gz: 3c04bbffeac4ba8709854f17f88a7f16557ba24a42d45ed8380e617c3fef15e2
4
+ data.tar.gz: 83bde885fe37e200291515807b6da9844d500cf5d1def6c9e3ca328c0a2c5944
5
5
  SHA512:
6
- metadata.gz: 31573e6b6cef57ee9fb3e8cef36b20ffed6a0e122cf667857daedc1c4049753f7a7bdfcee67f8400711708c9aed795f474dddc194fb1876aa71d654a75ee42e0
7
- data.tar.gz: ecd575021a0091b2f6f75d93416b09be0335e499498448b10383091ea4aa8eec1d110718b41a50486c54e6b8649fac45e9d06feed7fb0e3916c51461e677c5c0
6
+ metadata.gz: 5f49ed4d33a3db74085ce26fe10c2a1ff16a9cfe90aa93d0a8dd12695ae1ae4bcb1b19af3968480b872ff05f6538a7328a770447a90fa168529818d78d0abf97
7
+ data.tar.gz: f7143ce0a2d70daf82c24847a12b1d34710237d39d2479c7df4a1ee6e5740ad4fcd71c46647d140312621ef8deacaa4a3f0471b7c89344d7b3d5d330c8ddde52
data/README.md CHANGED
@@ -190,3 +190,9 @@ In that folder's config folder, create a `secret_settings.yml` file according to
190
190
  instructions in `secret_settings.yml.example`. Run the example server in the normal way (bundle install..., migrate db, rails server).
191
191
  7. Navigate to the home page, http://localhost:4000. Click log in and play around. You can also refresh the accounts site and see yourself logged in, log out, etc.
192
192
  8. For fun, change example/config/openstax_accounts.rb to set `enable_stubbing` to `true`. Now when you click login you'll be taken to a developer-only page where you can login as other users, generate new users, create new users, etc.
193
+
194
+ Additional Documentation
195
+ ------------------------
196
+
197
+ Additional documentation is in the [accounts-rails wiki](https://github.com/openstax/accounts-rails/wiki).
198
+
@@ -27,14 +27,18 @@ module OpenStax
27
27
  end
28
28
 
29
29
  def destroy
30
- sign_out!
31
-
32
- # Unless we are stubbing, we redirect to a configurable URL, which is normally
33
- # (or at least eventually) the Accounts logout URL so that users can't sign back
34
- # in automagically.
35
- redirect_to configuration.enable_stubbing? ?
36
- main_app.root_url :
37
- configuration.logout_redirect_url(request)
30
+ # if a handler is configured, let it handle everything
31
+ if configuration.logout_handler
32
+ configuration.logout_handler.call(self)
33
+ else
34
+ # Unless we are stubbing, we redirect to a configurable URL, which is normally
35
+ # (or at least eventually) the Accounts logout URL so that users can't sign back
36
+ # in automagically.
37
+ sign_out!
38
+ redirect_to configuration.enable_stubbing? ?
39
+ main_app.root_url :
40
+ configuration.logout_redirect_url(request)
41
+ end
38
42
  end
39
43
 
40
44
  def failure
@@ -5,6 +5,7 @@ module OpenStax::Accounts
5
5
  SYNC_ATTRIBUTES = [
6
6
  :openstax_uid,
7
7
  :username,
8
+ :is_administrator,
8
9
  :first_name,
9
10
  :last_name,
10
11
  :full_name,
@@ -16,7 +17,8 @@ module OpenStax::Accounts
16
17
  :salesforce_contact_id,
17
18
  :support_identifier,
18
19
  :is_test,
19
- :is_kip
20
+ :is_kip,
21
+ :grant_tutor_access
20
22
  ]
21
23
 
22
24
  attr_accessor :syncing
@@ -30,6 +30,12 @@ module OpenStax
30
30
  required: true
31
31
  }
32
32
 
33
+ property :is_administrator,
34
+ type: :boolean,
35
+ schema_info: {
36
+ description: 'Whether or not this user is an administrator on Accounts'
37
+ }
38
+
33
39
  property :first_name,
34
40
  type: String,
35
41
  schema_info: {
@@ -117,6 +123,12 @@ module OpenStax
117
123
  schema_info: {
118
124
  description: 'Whether or not this is a Key Institutional Partner account'
119
125
  }
126
+
127
+ property :grant_tutor_access,
128
+ type: :boolean,
129
+ schema_info: {
130
+ description: 'Whether or not the account should be granted Tutor access'
131
+ }
120
132
  end
121
133
  end
122
134
  end
@@ -1,3 +1,5 @@
1
+ require 'openstax_api'
2
+
1
3
  module OpenStax
2
4
  module Accounts
3
5
  module Api
@@ -7,7 +7,8 @@ module OpenStax
7
7
 
8
8
  def exec(email: nil, username: nil, password: nil, first_name: nil, last_name: nil,
9
9
  full_name: nil, title: nil, salesforce_contact_id: nil, faculty_status: nil,
10
- role: nil, school_type: nil, school_location: nil, is_kip: nil, is_test: nil)
10
+ role: nil, school_type: nil, school_location: nil, is_kip: nil,
11
+ grant_tutor_access: nil, is_test: nil)
11
12
  raise(
12
13
  ArgumentError,
13
14
  'You must specify either an email address or a username (and an optional password)'
@@ -24,7 +25,7 @@ module OpenStax
24
25
  first_name: first_name, last_name: last_name, full_name: full_name,
25
26
  salesforce_contact_id: salesforce_contact_id, faculty_status: faculty_status,
26
27
  role: role, school_type: school_type, school_location: school_location,
27
- is_kip: is_kip, is_test: is_test
28
+ is_kip: is_kip, grant_tutor_access: grant_tutor_access, is_test: is_test
28
29
  )
29
30
  fatal_error(code: :invalid_inputs) unless (200..202).include?(response.status)
30
31
 
@@ -49,6 +50,7 @@ module OpenStax
49
50
  account.school_location = school_location || :unknown_school_location
50
51
  account.support_identifier = support_identifier
51
52
  account.is_kip = is_kip
53
+ account.grant_tutor_access = grant_tutor_access
52
54
  account.is_test = is_test
53
55
  end
54
56
 
@@ -8,7 +8,7 @@ module OpenStax
8
8
  uid = attrs.delete('id')
9
9
  uuid = attrs.delete('uuid')
10
10
  account = Account.find_or_initialize_by(uuid: uuid)
11
- account.update_attributes!(attrs.slice(*Account.column_names))
11
+ account.update!(attrs.slice(*Account.column_names))
12
12
  transfer_errors_from(account, {type: :verbatim})
13
13
  outputs.account = account
14
14
  end
@@ -1,7 +1,5 @@
1
1
  # Routine for getting account updates from the Accounts server
2
- #
3
2
  # Should be scheduled to run regularly
4
-
5
3
  module OpenStax
6
4
  module Accounts
7
5
  class SyncAccounts
@@ -12,36 +10,40 @@ module OpenStax
12
10
  def exec(options={})
13
11
  return if OpenStax::Accounts.configuration.enable_stubbing?
14
12
 
15
- response = OpenStax::Accounts::Api.get_application_account_updates
13
+ loop do
14
+ response = OpenStax::Accounts::Api.get_application_account_updates
16
15
 
17
- app_accounts = []
18
- app_accounts_rep = OpenStax::Accounts::Api::V1::ApplicationAccountsRepresenter
19
- .new(app_accounts)
20
- app_accounts_rep.from_json(response.body)
16
+ app_accounts = []
17
+ app_accounts_rep = OpenStax::Accounts::Api::V1::ApplicationAccountsRepresenter.new(
18
+ app_accounts
19
+ )
20
+ app_accounts_rep.from_json(response.body)
21
21
 
22
- return if app_accounts.empty?
22
+ num_accounts = app_accounts.size
23
+ return if num_accounts == 0
23
24
 
24
- updated_app_accounts = []
25
- app_accounts.each do |app_account|
26
- account = OpenStax::Accounts::Account.find_by(
27
- uuid: app_account.account.uuid
28
- ) || app_account.account
29
- account.syncing = true
25
+ updated_app_accounts = []
26
+ app_accounts.each do |app_account|
27
+ account = OpenStax::Accounts::Account.find_by(
28
+ uuid: app_account.account.uuid
29
+ ) || app_account.account
30
+ account.syncing = true
30
31
 
31
- if account != app_account.account
32
32
  OpenStax::Accounts::Account::SYNC_ATTRIBUTES.each do |attribute|
33
- account.send("#{attribute}=", app_account.account.send(attribute))
34
- end
33
+ account.send "#{attribute}=", app_account.account.send(attribute)
34
+ end if account != app_account.account
35
+
36
+ next unless account.save
37
+
38
+ updated_app_accounts << {
39
+ user_id: account.openstax_uid, read_updates: app_account.unread_updates
40
+ }
35
41
  end
36
42
 
37
- next unless account.save
43
+ OpenStax::Accounts::Api.mark_account_updates_as_read(updated_app_accounts)
38
44
 
39
- updated_app_accounts << {
40
- user_id: account.openstax_uid, read_updates: app_account.unread_updates
41
- }
45
+ return if num_accounts < OpenStax::Accounts.configuration.max_user_updates_per_request
42
46
  end
43
-
44
- OpenStax::Accounts::Api.mark_account_updates_as_read(updated_app_accounts)
45
47
  end
46
48
  end
47
49
  end
@@ -0,0 +1,5 @@
1
+ class AddGrantTutorAccessToOpenStaxAccountsAccounts < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :openstax_accounts_accounts, :grant_tutor_access, :boolean
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddIsAdministratorToOpenStaxAccountsAccounts < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :openstax_accounts_accounts, :is_administrator, :boolean
4
+ end
5
+ end
@@ -81,7 +81,9 @@ module OpenStax
81
81
  # On success, returns an OAuth2::Response object.
82
82
  def self.get_application_account_updates(options = {})
83
83
  limit = OpenStax::Accounts.configuration.max_user_updates_per_request
84
- request(:get, "application_users/updates#{ '?limit=' + limit.to_s if !limit.blank? }", options)
84
+ request(
85
+ :get, "application_users/updates#{ '?limit=' + limit.to_s if !limit.blank? }", options
86
+ )
85
87
  end
86
88
 
87
89
  # Marks account updates as "read".
@@ -53,9 +53,16 @@ module OpenStax
53
53
  # If more would be returned, the result will be empty instead
54
54
  attr_accessor :max_search_items
55
55
 
56
+ # logout_handler
57
+ # Handles logging out and redirecting user when they've requested logout
58
+ # if specified, the logout_redirect_url has no effect
59
+ attr_accessor :logout_handler
60
+
56
61
  # logout_redirect_url
57
62
  # A URL to redirect to after the app logs out, can be a string or a Proc.
58
63
  # If a Proc (or lambda), it will be called with the logout request.
64
+ #
65
+ # Only used if the logout_handler above is not specified
59
66
  # If this field is nil or if the Proc returns nil, the logout will redirect
60
67
  # to the default Accounts logout URL.
61
68
  attr_writer :logout_redirect_url
@@ -117,6 +124,7 @@ module OpenStax
117
124
  @account_user_mapper = OpenStax::Accounts::DefaultAccountUserMapper
118
125
  @min_search_characters = 3
119
126
  @max_search_items = 10
127
+ @logout_handler = nil
120
128
  @logout_redirect_url = nil
121
129
  @return_to_url_approver = nil
122
130
  @forwardable_login_params = [
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Accounts
3
- VERSION = '9.3.0'
3
+ VERSION = '9.6.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_accounts
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.0
4
+ version: 9.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-22 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ">"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: omniauth
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ">="
37
+ - - "<"
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: '2.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ">="
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: '2.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: omniauth-oauth2
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -343,6 +349,8 @@ files:
343
349
  - db/migrate/15_drop_accounts_groups.rb
344
350
  - db/migrate/16_add_is_kip_to_openstax_accounts_accounts.rb
345
351
  - db/migrate/17_add_school_location_to_openstax_accounts_accounts.rb
352
+ - db/migrate/18_add_grant_tutor_access_to_openstax_accounts_accounts.rb
353
+ - db/migrate/19_add_is_administrator_to_openstax_accounts_accounts.rb
346
354
  - db/migrate/1_create_openstax_accounts_groups.rb
347
355
  - db/migrate/2_create_openstax_accounts_group_members.rb
348
356
  - db/migrate/3_create_openstax_accounts_group_owners.rb
@@ -385,7 +393,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
393
  - !ruby/object:Gem::Version
386
394
  version: '0'
387
395
  requirements: []
388
- rubygems_version: 3.0.3
396
+ rubygems_version: 3.2.6
389
397
  signing_key:
390
398
  specification_version: 4
391
399
  summary: Rails common code and bindings for the 'accounts' API