openstax_accounts 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/openstax/accounts/dev/accounts_controller.rb +9 -1
- data/app/handlers/openstax/accounts/dev/accounts_create.rb +33 -0
- data/app/handlers/openstax/accounts/dev/{accounts_index.rb → accounts_search.rb} +1 -1
- data/app/routines/openstax/accounts/dev/create_account.rb +37 -0
- data/app/views/openstax/accounts/dev/accounts/_search_results.html.erb +17 -15
- data/app/views/openstax/accounts/dev/accounts/index.html.erb +19 -6
- data/app/views/openstax/accounts/dev/accounts/search.js.erb +3 -0
- data/app/views/openstax/accounts/shared/accounts/{_index.html.erb → _search.html.erb} +1 -1
- data/config/routes.rb +3 -3
- data/lib/openstax/accounts/version.rb +1 -1
- metadata +7 -5
- data/app/views/openstax/accounts/dev/accounts/index.js.erb +0 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmM3YWJkNTYyYjhiNzE5YmQ3NmYxZDBmYTNiMDhmNzk3MTJmNjE3MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDljZjliNzE0NDFjY2M5NjI0ZGJiZWE2ZTY0MTVkZjYxOGI0YjIxZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODk1MzM5MThkNGQ3NTVkMzYyNjE4MmY2OGRhZTAyY2I5ZjBkZDViNDI2NDQz
|
10
|
+
YjdjYTkzMDI2OTk2YjJmN2E1YzhjODRhNTNjZThiNTM2MmNlNTdiYTQxZDAx
|
11
|
+
ZWZiODI1MzU1ZmQ4NjVkNzUxODljMjZhMDRjMWU4OGVmNmYyNjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmRiN2RlZmUzZTgxMTA1NWI3ZTEwMjY3Yzc0NmI3ZjE4NjcxYjNlOWI3MTM4
|
14
|
+
ODFjNDU5ZTcxZWNmMjA2YzFhYTMwMjkxNTEzZmUyMDFiNWFmNDQ2YjhlMzE1
|
15
|
+
MDhjZWE2ZTA2MzM5NGQ5N2QxOWVkZTkwY2U1NWViODRkMmY3MDI=
|
@@ -4,7 +4,15 @@ module OpenStax
|
|
4
4
|
class AccountsController < OpenStax::Accounts::Dev::BaseController
|
5
5
|
|
6
6
|
def index
|
7
|
-
|
7
|
+
end
|
8
|
+
|
9
|
+
def search
|
10
|
+
handle_with(AccountsSearch)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
handle_with(AccountsCreate,
|
15
|
+
complete: lambda { redirect_back })
|
8
16
|
end
|
9
17
|
|
10
18
|
def become
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module OpenStax
|
2
|
+
module Accounts
|
3
|
+
|
4
|
+
module Dev
|
5
|
+
class AccountsCreate
|
6
|
+
|
7
|
+
lev_handler
|
8
|
+
|
9
|
+
paramify :create do
|
10
|
+
attribute :username, type: String
|
11
|
+
validates :username, presence: true
|
12
|
+
end
|
13
|
+
|
14
|
+
uses_routine OpenStax::Accounts::Dev::CreateAccount,
|
15
|
+
as: :create_account,
|
16
|
+
translations: { inputs: { scope: :create },
|
17
|
+
outputs: { type: :verbatim } }
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def authorized?
|
22
|
+
!Rails.env.production? && OpenStax::Accounts.configuration.enable_stubbing?
|
23
|
+
end
|
24
|
+
|
25
|
+
def handle
|
26
|
+
run(:create_account, create_params.as_hash(:username))
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Routine for creating an account, only for use when stubbing and
|
2
|
+
# not on production.
|
3
|
+
|
4
|
+
module OpenStax
|
5
|
+
module Accounts
|
6
|
+
module Dev
|
7
|
+
class CreateAccount
|
8
|
+
lev_routine
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def exec(inputs={})
|
13
|
+
fatal_error(:code => :cannot_create_account_in_production) if Rails.env.production?
|
14
|
+
fatal_error(:code => :can_only_create_account_when_stubbing) if !OpenStax::Accounts.configuration.enable_stubbing?
|
15
|
+
|
16
|
+
username = inputs[:username]
|
17
|
+
while username.nil? || Account.where(username: username).exists? do
|
18
|
+
username = SecureRandom.hex(3).to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
account = OpenStax::Accounts::Account.new
|
22
|
+
|
23
|
+
account.openstax_uid = -SecureRandom.hex.to_i(16)
|
24
|
+
account.access_token = SecureRandom.hex.to_s
|
25
|
+
account.username = username
|
26
|
+
|
27
|
+
account.save
|
28
|
+
|
29
|
+
transfer_errors_from(account, {type: :verbatim}, true)
|
30
|
+
|
31
|
+
outputs[:account] = account
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -30,21 +30,23 @@
|
|
30
30
|
<% end %>
|
31
31
|
</div>
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
<div id='search-results-list'>
|
34
|
+
<%= osu.action_list(
|
35
|
+
records: accounts,
|
36
|
+
list: {
|
37
|
+
headings: ['Username', 'Title', 'Name', 'Actions'],
|
38
|
+
widths: ['30%', '10%', '40%', '20%'],
|
38
39
|
data_procs:
|
39
40
|
[
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
lambda { |account| account.username },
|
42
|
+
lambda { |account| account.title || '---' },
|
43
|
+
lambda { |account| account.name || '---' },
|
44
|
+
lambda { |account|
|
45
|
+
link_to 'Sign in as',
|
46
|
+
with_interceptor { become_dev_account_path(account) },
|
47
|
+
method: :post
|
48
|
+
}
|
48
49
|
]
|
49
|
-
|
50
|
-
|
50
|
+
}
|
51
|
+
) %>
|
52
|
+
</div>
|
@@ -4,15 +4,28 @@
|
|
4
4
|
<%= error.translate %>
|
5
5
|
<% end %>
|
6
6
|
|
7
|
-
|
7
|
+
<h3>Create an Account</h3>
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
<%= lev_form_for :create,
|
10
|
+
url: openstax_accounts.dev_accounts_path,
|
11
|
+
method: :post do |f| %>
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
Username
|
14
|
+
<%= f.text_field :username, style: 'width:300px' %>
|
15
|
+
<%= f.submit 'Create', class: 'btn btn-primary' %>
|
15
16
|
|
16
17
|
<% end %>
|
17
18
|
|
19
|
+
<h3>Development Login</h3>
|
20
|
+
|
21
|
+
<p>You need to login, but we're not connected to the Accounts server.
|
22
|
+
Search for a user below and click the sign in link next to him or her.</p>
|
23
|
+
|
24
|
+
<%= with_interceptor {
|
25
|
+
render :partial => 'openstax/accounts/shared/accounts/search',
|
26
|
+
:locals => { :search_action_path => openstax_accounts.search_dev_accounts_path,
|
27
|
+
:remote => true, :method => :get } } %>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
<div id="search-results"></div>
|
18
31
|
</div>
|
data/config/routes.rb
CHANGED
@@ -8,7 +8,7 @@ OpenStax::Accounts::Engine.routes.draw do
|
|
8
8
|
get '/auth/openstax', :as => 'openstax_login'
|
9
9
|
|
10
10
|
# OmniAuth local routes (SessionsController)
|
11
|
-
|
11
|
+
scope module: 'sessions' do
|
12
12
|
get 'callback', :path => 'auth/:provider/callback' # Authentication success
|
13
13
|
get 'failure', :path => 'auth/failure' # Authentication failure
|
14
14
|
|
@@ -19,9 +19,9 @@ OpenStax::Accounts::Engine.routes.draw do
|
|
19
19
|
|
20
20
|
if OpenStax::Accounts.configuration.enable_stubbing?
|
21
21
|
namespace :dev do
|
22
|
-
resources :accounts, :only => [:index] do
|
23
|
-
post 'index', :on => :collection
|
22
|
+
resources :accounts, :only => [:index, :create] do
|
24
23
|
post 'become', :on => :member
|
24
|
+
get 'search', :on => :collection
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_accounts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.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: 2014-09-
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -251,7 +251,8 @@ files:
|
|
251
251
|
- app/controllers/openstax/accounts/dev/accounts_controller.rb
|
252
252
|
- app/controllers/openstax/accounts/dev/base_controller.rb
|
253
253
|
- app/controllers/openstax/accounts/sessions_controller.rb
|
254
|
-
- app/handlers/openstax/accounts/dev/
|
254
|
+
- app/handlers/openstax/accounts/dev/accounts_create.rb
|
255
|
+
- app/handlers/openstax/accounts/dev/accounts_search.rb
|
255
256
|
- app/handlers/openstax/accounts/sessions_callback.rb
|
256
257
|
- app/helpers/openstax/accounts/application_helper.rb
|
257
258
|
- app/models/openstax/accounts/account.rb
|
@@ -272,6 +273,7 @@ files:
|
|
272
273
|
- app/representers/openstax/accounts/api/v1/group_nesting_representer.rb
|
273
274
|
- app/representers/openstax/accounts/api/v1/group_representer.rb
|
274
275
|
- app/representers/openstax/accounts/api/v1/group_user_representer.rb
|
276
|
+
- app/routines/openstax/accounts/dev/create_account.rb
|
275
277
|
- app/routines/openstax/accounts/dev/search_accounts.rb
|
276
278
|
- app/routines/openstax/accounts/search_accounts.rb
|
277
279
|
- app/routines/openstax/accounts/sync_accounts.rb
|
@@ -280,9 +282,9 @@ files:
|
|
280
282
|
- app/views/layouts/openstax/accounts/application.html.erb
|
281
283
|
- app/views/openstax/accounts/dev/accounts/_search_results.html.erb
|
282
284
|
- app/views/openstax/accounts/dev/accounts/index.html.erb
|
283
|
-
- app/views/openstax/accounts/dev/accounts/
|
285
|
+
- app/views/openstax/accounts/dev/accounts/search.js.erb
|
284
286
|
- app/views/openstax/accounts/shared/_attention.html.erb
|
285
|
-
- app/views/openstax/accounts/shared/accounts/
|
287
|
+
- app/views/openstax/accounts/shared/accounts/_search.html.erb
|
286
288
|
- config/initializers/action_interceptor.rb
|
287
289
|
- config/routes.rb
|
288
290
|
- db/migrate/0_create_openstax_accounts_accounts.rb
|