openstax_accounts 7.13.0 → 8.1.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 +4 -4
- data/app/controllers/openstax/accounts/application_controller.rb +1 -1
- data/app/controllers/openstax/accounts/dev/accounts_controller.rb +1 -1
- data/app/controllers/openstax/accounts/dev/base_controller.rb +1 -1
- data/app/controllers/openstax/accounts/sessions_controller.rb +7 -8
- data/app/handlers/openstax/accounts/sessions_callback.rb +17 -37
- data/app/models/openstax/accounts/account.rb +33 -1
- data/app/models/openstax/accounts/group.rb +12 -8
- data/app/models/openstax/accounts/group_nesting.rb +8 -7
- data/app/representers/openstax/accounts/api/v1/unclaimed_account_representer.rb +1 -7
- data/app/routines/openstax/accounts/find_or_create_account.rb +9 -9
- data/app/routines/openstax/accounts/find_or_create_from_sso.rb +23 -0
- data/app/routines/openstax/accounts/sync_accounts.rb +1 -6
- data/config/routes.rb +11 -11
- data/db/migrate/0_create_openstax_accounts_accounts.rb +1 -1
- data/db/migrate/10_assign_missing_uuids_for_local_accounts.rb +2 -2
- data/db/migrate/11_add_support_identifier_to_accounts_accounts.rb +1 -1
- data/db/migrate/12_add_is_test_to_accounts_accounts.rb +1 -1
- data/db/migrate/13_add_school_type_to_accounts_accounts.rb +1 -1
- data/db/migrate/1_create_openstax_accounts_groups.rb +1 -1
- data/db/migrate/2_create_openstax_accounts_group_members.rb +1 -1
- data/db/migrate/3_create_openstax_accounts_group_owners.rb +1 -1
- data/db/migrate/4_create_openstax_accounts_group_nestings.rb +1 -1
- data/db/migrate/5_add_faculty_status_to_accounts_accounts.rb +1 -1
- data/db/migrate/6_add_salesforce_contact_id_to_accounts_accounts.rb +1 -1
- data/db/migrate/7_change_accounts_openstax_uid_to_be_nullable.rb +1 -1
- data/db/migrate/8_change_accounts_username_to_be_nullable.rb +1 -1
- data/db/migrate/9_add_uuid_and_role_to_accounts_accounts.rb +1 -1
- data/lib/omniauth/strategies/openstax.rb +6 -23
- data/lib/openstax/accounts/configuration.rb +16 -0
- data/lib/openstax/accounts/current_user_manager.rb +20 -0
- data/lib/openstax/accounts/has_many_through_groups/active_record/base.rb +5 -5
- data/lib/openstax/accounts/sso.rb +61 -0
- data/lib/openstax/accounts/version.rb +1 -1
- data/lib/openstax_accounts.rb +6 -7
- data/lib/tasks/sync.rake +3 -3
- data/spec/factories/openstax_accounts_account.rb +1 -1
- data/spec/factories/openstax_accounts_group.rb +3 -3
- data/spec/factories/openstax_accounts_group_member.rb +1 -1
- data/spec/factories/openstax_accounts_group_nesting.rb +1 -1
- data/spec/factories/openstax_accounts_group_owner.rb +1 -1
- metadata +34 -212
- data/Rakefile +0 -22
- data/spec/cassettes/OpenStax_Accounts_FindOrCreateAccount/can_create_users.yml +0 -303
- data/spec/controllers/openstax/accounts/dev/accounts_controller_spec.rb +0 -27
- data/spec/controllers/openstax/accounts/forwards_params_spec.rb +0 -75
- data/spec/controllers/openstax/accounts/sessions_controller_spec.rb +0 -71
- data/spec/controllers/openstax/accounts/uses_this_engine_controller_spec.rb +0 -22
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/access_policies/account_access_policy.rb +0 -11
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/api/application_groups_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/application_users_controller.rb +0 -15
- data/spec/dummy/app/controllers/api/dummy_controller.rb +0 -12
- data/spec/dummy/app/controllers/api/group_members_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/group_nestings_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/group_owners_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/groups_controller.rb +0 -15
- data/spec/dummy/app/controllers/api/users_controller.rb +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/oauth_controller.rb +0 -10
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/anonymous_user.rb +0 -48
- data/spec/dummy/app/models/ownership.rb +0 -7
- data/spec/dummy/app/models/user.rb +0 -29
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/config/application.rb +0 -23
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -15
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -40
- data/spec/dummy/config/environments/production.rb +0 -82
- data/spec/dummy/config/environments/test.rb +0 -39
- data/spec/dummy/config/initializers/access_policies.rb +0 -1
- data/spec/dummy/config/initializers/assets.rb +0 -8
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/doorkeeper.rb +0 -75
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/openstax_accounts.rb +0 -14
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -45
- data/spec/dummy/config/secrets.yml +0 -8
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1000_create_users.rb +0 -11
- data/spec/dummy/db/migrate/1001_create_ownerships.rb +0 -11
- data/spec/dummy/db/schema.rb +0 -113
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -5137
- data/spec/dummy/log/test.log +0 -162651
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/handlers/openstax/accounts/accounts_search_spec.rb +0 -63
- data/spec/handlers/openstax/accounts/dev/accounts_search_spec.rb +0 -55
- data/spec/handlers/openstax/accounts/sessions_callback_spec.rb +0 -119
- data/spec/lib/openstax/accounts/api_spec.rb +0 -212
- data/spec/lib/openstax/accounts/configuration_spec.rb +0 -39
- data/spec/lib/openstax/accounts/current_user_manager_spec.rb +0 -157
- data/spec/lib/openstax/accounts/has_many_through_groups/active_record/base_spec.rb +0 -57
- data/spec/models/openstax/accounts/account_spec.rb +0 -114
- data/spec/models/openstax/accounts/anonymous_account_spec.rb +0 -9
- data/spec/models/openstax/accounts/group_spec.rb +0 -51
- data/spec/routines/openstax/accounts/create_group_spec.rb +0 -32
- data/spec/routines/openstax/accounts/find_or_create_account_spec.rb +0 -76
- data/spec/routines/openstax/accounts/search_accounts_shared_examples.rb +0 -160
- data/spec/routines/openstax/accounts/search_accounts_spec.rb +0 -6
- data/spec/routines/openstax/accounts/search_local_accounts_spec.rb +0 -6
- data/spec/routines/openstax/accounts/sync_accounts_spec.rb +0 -101
- data/spec/routines/openstax/accounts/sync_groups_spec.rb +0 -143
- data/spec/spec_helper.rb +0 -109
- data/spec/vcr_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edf27a81aef8f196ab5b804f38903395d24367628209a9eeb001a37f258f33d5
|
4
|
+
data.tar.gz: af2ac3a3de4ab707958bc03b0faf561e876b99521f82a8695a55cfcbbd1bc740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f8b506ad52a7bb2b59ed822f0347c7bb5343728dbedf7fa166f7ffc2aabc7ce9c3b8a6113d09aab44795a04e79e74595583e2335e825b0e682e7be3604b4a8c
|
7
|
+
data.tar.gz: fca6c2d52b5540bac193bc099c905ca4a6aa860c7353b411259ae95c878e872fb7c0f46f67c7b0a3813b7ae853dd967e969839c524384a07d1b30e3754677874
|
@@ -3,7 +3,7 @@ module OpenStax
|
|
3
3
|
module Dev
|
4
4
|
class AccountsController < OpenStax::Accounts::Dev::BaseController
|
5
5
|
# Allow accessing from inside an iframe
|
6
|
-
|
6
|
+
before_action :allow_iframe_access, only: [:index, :search]
|
7
7
|
|
8
8
|
def index
|
9
9
|
end
|
@@ -12,7 +12,7 @@ module OpenStax
|
|
12
12
|
redirect_to dev_accounts_path
|
13
13
|
else
|
14
14
|
forwardable_params =
|
15
|
-
params.
|
15
|
+
params.permit(*configuration.forwardable_login_param_keys.map(&:to_s)).to_h
|
16
16
|
redirect_to openstax_login_path(forwardable_params)
|
17
17
|
end
|
18
18
|
end
|
@@ -20,13 +20,12 @@ module OpenStax
|
|
20
20
|
def callback
|
21
21
|
handle_with(
|
22
22
|
SessionsCallback,
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
})
|
23
|
+
success: -> do
|
24
|
+
sign_in(@handler_result.outputs[:account])
|
25
|
+
redirect_back key: :accounts_return_to, strategies: [:session]
|
26
|
+
end,
|
27
|
+
failure: -> { failure }
|
28
|
+
)
|
30
29
|
end
|
31
30
|
|
32
31
|
def destroy
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module OpenStax
|
2
2
|
module Accounts
|
3
|
-
|
4
3
|
class SessionsCallback
|
5
|
-
|
6
4
|
lev_handler
|
7
5
|
|
8
6
|
protected
|
@@ -12,59 +10,41 @@ module OpenStax
|
|
12
10
|
end
|
13
11
|
|
14
12
|
def authorized?
|
15
|
-
@auth_data.provider ==
|
13
|
+
@auth_data.provider == 'openstax'
|
16
14
|
end
|
17
15
|
|
18
16
|
def handle
|
19
|
-
# Don't worry if the account is logged in or not beforehand.
|
20
|
-
# Just assume that they aren't.
|
17
|
+
# Don't worry if the account is logged in or not beforehand. Just assume that they aren't.
|
21
18
|
|
22
|
-
#
|
19
|
+
# tap is used because we want the block to always run (not just when initializing)
|
23
20
|
begin
|
24
|
-
outputs
|
25
|
-
|
26
|
-
|
27
|
-
account.last_name = @auth_data.info.last_name
|
28
|
-
account.full_name = @auth_data.info.name
|
29
|
-
account.title = @auth_data.info.title
|
21
|
+
outputs.account = Account.find_or_initialize_by(
|
22
|
+
openstax_uid: @auth_data.uid
|
23
|
+
).tap do |account|
|
30
24
|
account.access_token = @auth_data.credentials.token
|
31
25
|
|
32
|
-
# Gracefully handle absent and unknown faculty status info
|
33
26
|
raw_info = @auth_data.extra.raw_info
|
34
|
-
|
35
|
-
begin
|
36
|
-
account.faculty_status = raw_info['faculty_status'] || :no_faculty_info
|
37
|
-
rescue ArgumentError => ee
|
38
|
-
account.faculty_status = :no_faculty_info
|
39
|
-
end
|
40
|
-
|
41
|
-
begin
|
42
|
-
account.role = raw_info['self_reported_role'] || :unknown_role
|
43
|
-
rescue ArgumentError => ee
|
44
|
-
account.role = :unknown_role
|
45
|
-
end
|
46
|
-
|
27
|
+
OpenStax::Accounts::Account::SYNC_ATTRIBUTES.each do |attribute|
|
47
28
|
begin
|
48
|
-
account.
|
49
|
-
rescue ArgumentError
|
50
|
-
|
29
|
+
account.send "#{attribute}=", raw_info[attribute]
|
30
|
+
rescue ArgumentError
|
31
|
+
# Ignore errors, for example if enum values are invalid
|
51
32
|
end
|
52
|
-
|
53
|
-
account.uuid = raw_info['uuid']
|
54
|
-
account.support_identifier = raw_info['support_identifier']
|
55
|
-
account.is_test = raw_info['is_test']
|
56
33
|
end
|
34
|
+
|
35
|
+
# Gracefully handle absent and unknown enum values
|
36
|
+
account.faculty_status ||= :no_faculty_info
|
37
|
+
account.role ||= :unknown_role
|
38
|
+
account.school_type ||= :unknown_school_type
|
57
39
|
end
|
58
40
|
|
59
|
-
outputs
|
41
|
+
outputs.account.save if outputs.account.changed?
|
60
42
|
rescue ActiveRecord::RecordNotUnique
|
61
43
|
retry
|
62
44
|
end
|
63
45
|
|
64
|
-
transfer_errors_from(outputs
|
46
|
+
transfer_errors_from(outputs.account, type: :verbatim)
|
65
47
|
end
|
66
|
-
|
67
48
|
end
|
68
|
-
|
69
49
|
end
|
70
50
|
end
|
@@ -3,6 +3,20 @@ module OpenStax::Accounts
|
|
3
3
|
|
4
4
|
USERNAME_DISCARDED_CHAR_REGEX = /[^A-Za-z\d_]/
|
5
5
|
USERNAME_MAX_LENGTH = 50
|
6
|
+
SYNC_ATTRIBUTES = [
|
7
|
+
:username,
|
8
|
+
:first_name,
|
9
|
+
:last_name,
|
10
|
+
:full_name,
|
11
|
+
:title,
|
12
|
+
:self_reported_role,
|
13
|
+
:faculty_status,
|
14
|
+
:school_type,
|
15
|
+
:salesforce_contact_id,
|
16
|
+
:uuid,
|
17
|
+
:support_identifier,
|
18
|
+
:is_test
|
19
|
+
]
|
6
20
|
|
7
21
|
attr_accessor :syncing
|
8
22
|
|
@@ -21,7 +35,17 @@ module OpenStax::Accounts
|
|
21
35
|
has_many :groups_as_member, through: :group_members, source: :group
|
22
36
|
|
23
37
|
enum faculty_status: [:no_faculty_info, :pending_faculty, :confirmed_faculty, :rejected_faculty]
|
24
|
-
enum role: [
|
38
|
+
enum role: [
|
39
|
+
:unknown_role,
|
40
|
+
:student,
|
41
|
+
:instructor,
|
42
|
+
:administrator,
|
43
|
+
:librarian,
|
44
|
+
:designer,
|
45
|
+
:other,
|
46
|
+
:adjunct,
|
47
|
+
:homeschool
|
48
|
+
]
|
25
49
|
enum school_type: [:unknown_school_type, :other_school_type, :college]
|
26
50
|
|
27
51
|
validates :faculty_status, :role, :school_type, presence: true
|
@@ -53,6 +77,14 @@ module OpenStax::Accounts
|
|
53
77
|
!openstax_uid.nil? && openstax_uid > 0
|
54
78
|
end
|
55
79
|
|
80
|
+
def self_reported_role
|
81
|
+
role
|
82
|
+
end
|
83
|
+
|
84
|
+
def self_reported_role=(role)
|
85
|
+
self.role = role
|
86
|
+
end
|
87
|
+
|
56
88
|
protected
|
57
89
|
|
58
90
|
def syncing_or_stubbing?
|
@@ -115,10 +115,12 @@ module OpenStax::Accounts
|
|
115
115
|
reload
|
116
116
|
|
117
117
|
gids = [openstax_uid] + (
|
118
|
-
self.class.joins(:member_group_nestings)
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
self.class.joins(:member_group_nestings).where(
|
119
|
+
# This could have been:
|
120
|
+
# member_group_nestings: { member_group_id: openstax_uid }
|
121
|
+
# However that needs a monkeypatch to work in Rails 5 so we currently do this:
|
122
|
+
openstax_accounts_group_nestings: { member_group_id: openstax_uid }
|
123
|
+
).first.try!(:supertree_group_ids) || []
|
122
124
|
)
|
123
125
|
update_column(:cached_supertree_group_ids, gids)
|
124
126
|
self.cached_supertree_group_ids = gids
|
@@ -129,10 +131,12 @@ module OpenStax::Accounts
|
|
129
131
|
return [] unless persisted?
|
130
132
|
reload
|
131
133
|
|
132
|
-
gids = [openstax_uid] +
|
133
|
-
|
134
|
-
|
135
|
-
|
134
|
+
gids = [openstax_uid] + self.class.joins(:container_group_nesting).where(
|
135
|
+
# This could have been:
|
136
|
+
# container_group_nesting: { container_group_id: openstax_uid }
|
137
|
+
# However that needs a monkeypatch to work in Rails 5 so we currently do this:
|
138
|
+
openstax_accounts_group_nestings: { container_group_id: openstax_uid }
|
139
|
+
).map { |group| group.subtree_group_ids }.flatten
|
136
140
|
update_column(:cached_subtree_group_ids, gids)
|
137
141
|
self.cached_subtree_group_ids = gids
|
138
142
|
end
|
@@ -26,25 +26,26 @@ module OpenStax::Accounts
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def no_loops
|
29
|
-
return if member_group.nil?
|
30
|
-
|
29
|
+
return if member_group.nil? || !member_group.subtree_group_ids.include?(container_group_id)
|
30
|
+
|
31
31
|
errors.add(:base, 'would create a loop') if errors[:base].blank?
|
32
|
-
|
32
|
+
throw :abort
|
33
33
|
end
|
34
34
|
|
35
35
|
def update_group_caches
|
36
|
-
|
37
|
-
|
36
|
+
UpdateGroupCaches.call(self)
|
37
|
+
|
38
|
+
throw(:abort) if errors.any?
|
38
39
|
end
|
39
40
|
|
40
41
|
def create_openstax_accounts_group_nesting
|
41
|
-
|
42
|
+
throw(:abort) if requestor.nil? || requestor.is_anonymous?
|
42
43
|
|
43
44
|
OpenStax::Accounts::Api.create_group_nesting(requestor, self) if requestor.has_authenticated?
|
44
45
|
end
|
45
46
|
|
46
47
|
def destroy_openstax_accounts_group_nesting
|
47
|
-
|
48
|
+
throw(:abort) if requestor.nil? || requestor.is_anonymous?
|
48
49
|
|
49
50
|
OpenStax::Accounts::Api.destroy_group_nesting(requestor, self) \
|
50
51
|
if requestor.has_authenticated?
|
@@ -4,7 +4,7 @@ module OpenStax
|
|
4
4
|
module V1
|
5
5
|
class UnclaimedAccountRepresenter < Roar::Decorator
|
6
6
|
|
7
|
-
# This representer is used to
|
7
|
+
# This representer is used to read from Accounts
|
8
8
|
# and so must allow read/write on all properties
|
9
9
|
# Do not use it in create/update APIs!
|
10
10
|
|
@@ -30,12 +30,6 @@ module OpenStax
|
|
30
30
|
description: "The unclaimed account's support_identifier"
|
31
31
|
}
|
32
32
|
|
33
|
-
property :is_test,
|
34
|
-
type: :boolean,
|
35
|
-
schema_info: {
|
36
|
-
description: "Whether or not this is a test account"
|
37
|
-
}
|
38
|
-
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -6,12 +6,13 @@ module OpenStax
|
|
6
6
|
|
7
7
|
protected
|
8
8
|
|
9
|
-
def exec(email: nil, username: nil, password: nil,
|
10
|
-
|
11
|
-
|
12
|
-
raise
|
13
|
-
|
14
|
-
|
9
|
+
def exec(email: nil, username: nil, password: nil, first_name: nil, last_name: nil,
|
10
|
+
full_name: nil, title: nil, salesforce_contact_id: nil, faculty_status: nil,
|
11
|
+
role: nil, school_type: nil, is_test: nil)
|
12
|
+
raise(
|
13
|
+
ArgumentError,
|
14
|
+
'You must specify either an email address or a username (and an optional password)'
|
15
|
+
) if email.nil? && username.nil?
|
15
16
|
|
16
17
|
if OpenStax::Accounts.configuration.enable_stubbing
|
17
18
|
# We can only stub finding by username b/c accounts-rails doesn't persist emails
|
@@ -24,7 +25,7 @@ module OpenStax
|
|
24
25
|
email: email, username: username, password: password,
|
25
26
|
first_name: first_name, last_name: last_name, full_name: full_name,
|
26
27
|
salesforce_contact_id: salesforce_contact_id, faculty_status: faculty_status,
|
27
|
-
role: role, school_type: school_type)
|
28
|
+
role: role, school_type: school_type, is_test: is_test)
|
28
29
|
fatal_error(code: :invalid_inputs) unless (200..202).include?(response.status)
|
29
30
|
|
30
31
|
struct = OpenStruct.new
|
@@ -32,7 +33,6 @@ module OpenStax
|
|
32
33
|
id = struct.id
|
33
34
|
uuid = struct.uuid
|
34
35
|
support_identifier = struct.support_identifier
|
35
|
-
is_test = struct.is_test
|
36
36
|
end
|
37
37
|
|
38
38
|
account = Account.find_or_initialize_by(openstax_uid: id)
|
@@ -57,7 +57,7 @@ module OpenStax
|
|
57
57
|
end
|
58
58
|
|
59
59
|
transfer_errors_from(account, {type: :verbatim}, true)
|
60
|
-
outputs
|
60
|
+
outputs.account = account
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module OpenStax
|
2
|
+
module Accounts
|
3
|
+
class FindOrCreateFromSso
|
4
|
+
|
5
|
+
lev_routine express_output: :account
|
6
|
+
|
7
|
+
def exec(attrs)
|
8
|
+
attrs.stringify_keys!
|
9
|
+
uid = attrs.delete('id')
|
10
|
+
uuid = attrs.delete('uuid')
|
11
|
+
account = Account.find_or_initialize_by(
|
12
|
+
uuid: uuid, openstax_uid: uid
|
13
|
+
)
|
14
|
+
account.update_attributes!(
|
15
|
+
attrs.slice(*Account.column_names)
|
16
|
+
)
|
17
|
+
transfer_errors_from(account, {type: :verbatim})
|
18
|
+
outputs.account = account
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -7,11 +7,6 @@ module OpenStax
|
|
7
7
|
|
8
8
|
class SyncAccounts
|
9
9
|
|
10
|
-
SYNC_ATTRIBUTES = [
|
11
|
-
'username', 'first_name', 'last_name', 'full_name', 'title', 'role', 'faculty_status',
|
12
|
-
'school_type', 'salesforce_contact_id', 'uuid', 'support_identifier', 'is_test'
|
13
|
-
]
|
14
|
-
|
15
10
|
lev_routine transaction: :no_transaction
|
16
11
|
|
17
12
|
protected
|
@@ -37,7 +32,7 @@ module OpenStax
|
|
37
32
|
account.syncing = true
|
38
33
|
|
39
34
|
if account != app_account.account
|
40
|
-
SYNC_ATTRIBUTES.each do |attribute|
|
35
|
+
OpenStax::Accounts::Account::SYNC_ATTRIBUTES.each do |attribute|
|
41
36
|
account.send("#{attribute}=", app_account.account.send(attribute))
|
42
37
|
end
|
43
38
|
end
|
data/config/routes.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
OpenStax::Accounts::Engine.routes.draw do
|
2
2
|
|
3
3
|
# Redirect here if we don't know what to do (theoretically should not happen)
|
4
|
-
root :
|
4
|
+
root to: 'sessions#new'
|
5
5
|
|
6
6
|
# Shortcut to OmniAuth route that redirects to the Accounts server
|
7
7
|
# This is provided by OmniAuth and is not in the SessionsController
|
8
|
-
get '/auth/openstax', :
|
8
|
+
get '/auth/openstax', as: 'openstax_login'
|
9
9
|
|
10
10
|
# User profile route
|
11
11
|
if OpenStax::Accounts.configuration.enable_stubbing?
|
12
12
|
namespace :dev do
|
13
|
-
resources :accounts, :
|
14
|
-
post 'become', :
|
15
|
-
get 'search', :
|
13
|
+
resources :accounts, only: [:index, :create] do
|
14
|
+
post 'become', on: :member
|
15
|
+
get 'search', on: :collection
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
# OmniAuth local routes (SessionsController)
|
21
21
|
scope module: 'sessions' do
|
22
|
-
get 'callback', :
|
23
|
-
get 'failure', :
|
22
|
+
get 'auth/:provider/callback', action: :callback, as: :callback # Authentication success
|
23
|
+
get 'auth/failure', action: :failure, as: :failure # Authentication failure
|
24
24
|
|
25
|
-
get 'login', :
|
26
|
-
match 'logout', :
|
27
|
-
:
|
28
|
-
get 'profile', :
|
25
|
+
get 'login', action: :new # Redirects to /auth/openstax or stub
|
26
|
+
match 'logout', action: :destroy, # Redirects to logout path or stub
|
27
|
+
via: OpenStax::Accounts.configuration.logout_via
|
28
|
+
get 'profile', action: :profile # Redirects to profile path or stub
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|