openstax_accounts 9.5.0 → 9.7.0
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 +4 -4
- data/README.md +6 -1
- data/app/models/openstax/accounts/account.rb +1 -0
- data/app/representers/openstax/accounts/api/v1/account_representer.rb +6 -0
- data/app/representers/openstax/accounts/api/v1/account_search_representer.rb +2 -0
- data/app/routines/openstax/accounts/find_or_create_from_sso.rb +1 -1
- data/app/routines/openstax/accounts/sync_accounts.rb +25 -23
- data/config/routes.rb +2 -2
- data/db/migrate/19_add_is_administrator_to_openstax_accounts_accounts.rb +5 -0
- data/lib/openstax/accounts/api.rb +3 -1
- data/lib/openstax/accounts/version.rb +1 -1
- metadata +18 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57482982ec158c16ae7ad70aadbf9bda911cd56b27fa4bfdab86c74c6ce008b2
|
4
|
+
data.tar.gz: fb98bd455ce7f4758d7a862305e83048b8809b1548d1bd87eaa596f433a8f820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9a7247488af4a6a96bbb8bb81ead9ea2208efd896a0590a4767c2c7ba88913a8deec5ef9661b72ac15d66f0be489c5177c28c277c527f65e923c904b1bb3038
|
7
|
+
data.tar.gz: aa45a18b1bc00ed0db4f6ab13ca85ea54dcb25be4a00dc356d202e3d00033cc8162b1c039e86f5a0c0b0932102c04e6cb657a830b20c2963b6a722c6adf0aa6c
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ accounts-rails
|
|
2
2
|
=============
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/openstax_accounts)
|
5
|
-
[](https://github.com/openstax/accounts-rails/actions?query=workflow:Tests)
|
6
6
|
[](https://codeclimate.com/github/openstax/accounts-rails)
|
7
7
|
|
8
8
|
A rails engine for interfacing with OpenStax's accounts server.
|
@@ -190,3 +190,8 @@ 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).
|
@@ -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: {
|
@@ -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.
|
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
|
-
|
13
|
+
loop do
|
14
|
+
response = OpenStax::Accounts::Api.get_application_account_updates
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
22
|
+
num_accounts = app_accounts.size
|
23
|
+
return if num_accounts == 0
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
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
|
-
|
43
|
+
OpenStax::Accounts::Api.mark_account_updates_as_read(updated_app_accounts)
|
38
44
|
|
39
|
-
|
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
|
data/config/routes.rb
CHANGED
@@ -17,8 +17,8 @@ OpenStax::Accounts::Engine.routes.draw do
|
|
17
17
|
|
18
18
|
# OmniAuth local routes (SessionsController)
|
19
19
|
scope module: 'sessions' do
|
20
|
-
get 'auth
|
21
|
-
get 'auth/failure', action: :failure, as: :failure
|
20
|
+
get 'auth/openstax/callback', action: :callback, as: :callback # Authentication success
|
21
|
+
get 'auth/failure', action: :failure, as: :failure # Authentication failure
|
22
22
|
|
23
23
|
get 'login', action: :new # Redirects to /auth/openstax or stub
|
24
24
|
match 'logout', action: :destroy, # Redirects to logout path or stub
|
@@ -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(
|
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".
|
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.
|
4
|
+
version: 9.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-08 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
|
@@ -86,14 +92,14 @@ dependencies:
|
|
86
92
|
requirements:
|
87
93
|
- - ">="
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
95
|
+
version: '1.0'
|
90
96
|
type: :runtime
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - ">="
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
102
|
+
version: '1.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: lev
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -344,6 +350,7 @@ files:
|
|
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
|
346
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
|
347
354
|
- db/migrate/1_create_openstax_accounts_groups.rb
|
348
355
|
- db/migrate/2_create_openstax_accounts_group_members.rb
|
349
356
|
- db/migrate/3_create_openstax_accounts_group_owners.rb
|
@@ -386,7 +393,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
393
|
- !ruby/object:Gem::Version
|
387
394
|
version: '0'
|
388
395
|
requirements: []
|
389
|
-
rubygems_version: 3.
|
396
|
+
rubygems_version: 3.2.6
|
390
397
|
signing_key:
|
391
398
|
specification_version: 4
|
392
399
|
summary: Rails common code and bindings for the 'accounts' API
|