openstax_connect 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. data/README.md +16 -0
  2. data/app/controllers/openstax/connect/application_controller.rb +7 -3
  3. data/app/controllers/openstax/connect/dev/dev_controller.rb +2 -0
  4. data/app/controllers/openstax/connect/sessions_controller.rb +3 -1
  5. data/app/handlers/openstax/connect/dev/users_create.rb +22 -25
  6. data/app/handlers/openstax/connect/dev/users_generate.rb +4 -2
  7. data/app/handlers/openstax/connect/dev/users_search.rb +7 -5
  8. data/app/handlers/openstax/connect/sessions_omniauth_authenticated.rb +11 -4
  9. data/app/helpers/openstax/connect/application_helper.rb +1 -1
  10. data/app/models/openstax/connect/user.rb +40 -0
  11. data/app/{algorithms → routines}/openstax/connect/search_users.rb +4 -4
  12. data/app/views/openstax/connect/dev/users/index.html.erb +4 -5
  13. data/app/views/openstax/connect/dev/users/search.js.erb +1 -1
  14. data/config/initializers/01_requires.rb +1 -0
  15. data/config/initializers/02_extend_builtins.rb +43 -17
  16. data/db/migrate/20130729213800_create_openstax_connect_users.rb +15 -0
  17. data/lib/omniauth/strategies/openstax.rb +4 -2
  18. data/lib/openstax/connect/engine.rb +2 -1
  19. data/lib/openstax/connect/exceptions.rb +3 -0
  20. data/lib/openstax/connect/user_provider.rb +13 -0
  21. data/lib/openstax/connect/version.rb +1 -1
  22. data/lib/openstax_connect.rb +43 -1
  23. metadata +12 -12
  24. data/app/controllers/openstax/connect/dev/sessions_controller.rb +0 -21
  25. data/app/models/anonymous_user.rb +0 -40
  26. data/app/models/user.rb +0 -21
  27. data/db/migrate/20130729213800_create_users.rb +0 -9
  28. data/db/migrate/20130909215452_add_fields_to_user.rb +0 -11
data/README.md CHANGED
@@ -39,6 +39,22 @@ Make sure to install the engine's migrations:
39
39
 
40
40
  rake openstax_connect:install:migrations
41
41
 
42
+ You also need to create your own User and AnonymousUser models. Once you do this, include concerns from the connect gem to get their baseline functionality.
43
+
44
+ class User < ActiveRecord::Base
45
+ include OpenStax::Connect::Models::User
46
+ ...
47
+ end
48
+
49
+ and
50
+
51
+ class AnonymousUser < ActiveRecord::Base
52
+ include OpenStax::Connect::Models::AnonymousUser
53
+ ...
54
+ end
55
+
56
+ Check out the engine code in app/concerns to see what this gets you.
57
+
42
58
  Example Application
43
59
  -------------------
44
60
 
@@ -1,9 +1,13 @@
1
1
  # References:
2
2
  # http://edgeguides.rubyonrails.org/engines.html#using-a-class-provided-by-the-application
3
3
 
4
- # Inherit from the applications ApplicationController to share some methods
5
- class OpenStax::Connect::ApplicationController < ApplicationController
4
+ module OpenStax
5
+ module Connect
6
6
 
7
- include Lev::HandleWith
7
+ # Inherit from the applications ApplicationController to share some methods
8
+ class ApplicationController < ::ApplicationController
9
+ include Lev::HandleWith
10
+ end
8
11
 
12
+ end
9
13
  end
@@ -5,6 +5,8 @@ module OpenStax
5
5
  module Dev
6
6
  class DevController < ApplicationController
7
7
 
8
+ skip_before_filter :authenticate_user!
9
+
8
10
  before_filter Proc.new{
9
11
  raise SecurityTransgression unless !Rails.env.production? ||
10
12
  current_user.is_administrator?
@@ -4,6 +4,8 @@ module OpenStax
4
4
  module Connect
5
5
  class SessionsController < ApplicationController
6
6
 
7
+ skip_before_filter :authenticate_user!
8
+
7
9
  def new
8
10
  session[:return_to] = request.referrer
9
11
  redirect_to RouteHelper.get_path(:login)
@@ -12,7 +14,7 @@ module OpenStax
12
14
  def omniauth_authenticated
13
15
  handle_with(SessionsOmniauthAuthenticated,
14
16
  complete: lambda {
15
- sign_in(@results[:user_to_sign_in])
17
+ connect_sign_in(@handler_result.outputs[:connect_user_to_sign_in])
16
18
  redirect_to return_path(true)
17
19
  })
18
20
  end
@@ -1,31 +1,28 @@
1
- class OpenStax::Connect::Dev::UsersCreate
2
- include Lev::Handler
1
+ module OpenStax::Connect::Dev
2
+ class UsersCreate
3
+ lev_handler
3
4
 
4
- protected
5
+ protected
5
6
 
6
- def setup
7
- end
8
-
9
- def authorized?
10
- !Rails.env.production?
11
- end
12
-
13
- def exec
14
- u = User.create do |user|
15
- user.first_name = params[:register][:first_name]
16
- user.last_name = params[:register][:last_name]
17
- user.username = params[:register][:username]
18
- user.is_administrator = params[:register][:is_administrator]
19
- user.openstax_uid = available_openstax_uid
7
+ def authorized?
8
+ !Rails.env.production?
20
9
  end
21
-
22
- transfer_errors_from(u, :register)
23
10
 
24
- results[:user] = u
25
- end
11
+ def handle
12
+ outputs[:user] = User.create do |user|
13
+ user.first_name = params[:register][:first_name]
14
+ user.last_name = params[:register][:last_name]
15
+ user.username = params[:register][:username]
16
+ user.is_administrator = params[:register][:is_administrator]
17
+ user.openstax_uid = available_openstax_uid
18
+ end
19
+
20
+ transfer_errors_from(outputs[:user], {scope: :register})
21
+ end
26
22
 
27
- def available_openstax_uid
28
- (User.order("openstax_uid DESC").first.try(:openstax_uid) || 0) + 1
29
- end
23
+ def available_openstax_uid
24
+ (User.order("openstax_uid DESC").first.try(:openstax_uid) || 0) + 1
25
+ end
30
26
 
31
- end
27
+ end
28
+ end
@@ -1,6 +1,6 @@
1
1
  module OpenStax::Connect::Dev
2
2
  class UsersGenerate
3
- include Lev::Handler
3
+ lev_handler
4
4
 
5
5
  protected
6
6
 
@@ -14,7 +14,7 @@ module OpenStax::Connect::Dev
14
14
  !Rails.env.production?
15
15
  end
16
16
 
17
- def exec
17
+ def handle
18
18
  generate_params.count.times do
19
19
  while !(User.where(:username => (username = SecureRandom.hex(4))).empty?) do; end
20
20
 
@@ -25,6 +25,8 @@ module OpenStax::Connect::Dev
25
25
  user.is_administrator = false
26
26
  user.openstax_uid = available_openstax_uid
27
27
  end
28
+
29
+ result.outputs.add(:users, u)
28
30
  end
29
31
  end
30
32
 
@@ -1,8 +1,8 @@
1
1
  module OpenStax::Connect::Dev
2
2
  class UsersSearch
3
3
 
4
- include Lev::Handler
5
-
4
+ lev_handler transaction: :no_transaction
5
+
6
6
  paramify :search do
7
7
  attribute :search_type, type: String
8
8
  validates :search_type, presence: true,
@@ -13,7 +13,9 @@ module OpenStax::Connect::Dev
13
13
  validates :search_terms, presence: true
14
14
  end
15
15
 
16
- uses_routine OpenStax::Connect::SearchUsers, as: :search_users
16
+ uses_routine OpenStax::Connect::SearchUsers,
17
+ as: :search_users,
18
+ translations: { outputs: {type: :verbatim} }
17
19
 
18
20
  protected
19
21
 
@@ -21,11 +23,11 @@ module OpenStax::Connect::Dev
21
23
  !Rails.env.production? || caller.is_administrator?
22
24
  end
23
25
 
24
- def exec
26
+ def handle
25
27
  terms = search_params.search_terms
26
28
  type = search_params.search_type
27
29
 
28
- results[:users] = run(:search_users, terms, type.downcase.to_sym)
30
+ run(:search_users, terms, type.downcase.to_sym)
29
31
  end
30
32
 
31
33
  end
@@ -1,7 +1,7 @@
1
1
  module OpenStax::Connect
2
2
 
3
3
  class SessionsOmniauthAuthenticated
4
- include Lev::Handler
4
+ lev_handler
5
5
 
6
6
  protected
7
7
 
@@ -13,8 +13,8 @@ module OpenStax::Connect
13
13
  @auth_data.provider == "openstax"
14
14
  end
15
15
 
16
- def exec
17
- results[:user_to_sign_in] = user_to_sign_in
16
+ def handle
17
+ outputs[:connect_user_to_sign_in] = user_to_sign_in
18
18
  end
19
19
 
20
20
  def user_to_sign_in
@@ -26,9 +26,16 @@ module OpenStax::Connect
26
26
  existing_user = User.where(openstax_uid: @auth_data.uid).first
27
27
  return existing_user if !existing_user.nil?
28
28
 
29
- return User.create do |user|
29
+ new_user = User.create do |user|
30
30
  user.openstax_uid = @auth_data.uid
31
+ user.username = @auth_data.info.username
32
+ user.first_name = @auth_data.info.first_name
33
+ user.last_name = @auth_data.info.last_name
31
34
  end
35
+
36
+ transfer_errors_from(new_user, {type: :verbatim})
37
+
38
+ new_user
32
39
  end
33
40
  end
34
41
 
@@ -3,7 +3,7 @@ module OpenStax
3
3
  module ApplicationHelper
4
4
 
5
5
  def unless_errors(options={}, &block)
6
- options[:errors] ||= @errors
6
+ options[:errors] ||= @handler_result.errors
7
7
  options[:errors_html_id] ||= OpenStax::Connect.configuration.default_errors_html_id
8
8
  options[:errors_partial] ||= OpenStax::Connect.configuration.default_errors_partial
9
9
  options[:trigger] ||= OpenStax::Connect.configuration.default_errors_added_trigger
@@ -0,0 +1,40 @@
1
+ module OpenStax::Connect
2
+ class User < ActiveRecord::Base
3
+
4
+ validates :username, uniqueness: true
5
+ validates :username, presence: true
6
+ validates :openstax_uid, presence: true
7
+
8
+ # first and last names are not required
9
+
10
+ def name
11
+ (first_name || last_name) ? [first_name, last_name].compact.join(" ") : username
12
+ end
13
+
14
+ def casual_name
15
+ first_name || username
16
+ end
17
+
18
+ def is_anonymous?
19
+ is_anonymous == true
20
+ end
21
+
22
+ attr_accessor :is_anonymous
23
+
24
+ def self.anonymous
25
+ @@anonymous ||= AnonymousUser.new
26
+ end
27
+
28
+ class AnonymousUser < User
29
+ before_save { false }
30
+ def initialize(attributes=nil)
31
+ super
32
+ self.is_anonymous = true
33
+ self.first_name = 'Guest'
34
+ self.last_name = 'User'
35
+ self.openstax_uid = nil
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -1,7 +1,7 @@
1
1
  module OpenStax::Connect
2
2
 
3
3
  class SearchUsers
4
- include Lev::Algorithm
4
+ lev_routine transaction: :no_transaction
5
5
 
6
6
  protected
7
7
 
@@ -21,7 +21,7 @@ module OpenStax::Connect
21
21
  end
22
22
  when :username
23
23
  query = terms.gsub('%', '') + '%'
24
- users = where{username =~ query}
24
+ users = User.where{username =~ query}
25
25
  when :any
26
26
  users = User.scoped
27
27
  terms.gsub(/[%,]/, '').split.each do |t|
@@ -32,10 +32,10 @@ module OpenStax::Connect
32
32
  (username =~ query)}
33
33
  end
34
34
  else
35
- raise IllegalArgument, "Unknown user search type: #{type.to_s}"
35
+ fatal_error(:unknown_user_search_type, data: type)
36
36
  end
37
37
 
38
- return users
38
+ outputs[:users] = users
39
39
  end
40
40
 
41
41
  end
@@ -3,8 +3,7 @@
3
3
  <%= error.translate %>
4
4
  <% end %>
5
5
 
6
- <%= osu_section_block "Register a new user" do %>
7
-
6
+ <%= osu.section_block "Register a new user" do %>
8
7
 
9
8
  <%= lev_form_for :register, url: dev_users_create_path do |f| %>
10
9
 
@@ -18,14 +17,14 @@
18
17
 
19
18
  <% end %>
20
19
 
21
- <%= osu_section_block "Generate new users" do %>
20
+ <%= osu.section_block "Generate new users" do %>
22
21
  <%= lev_form_for :generate, url: dev_users_generate_path do |f| %>
23
22
  Generate <%= f.text_field :count, style: 'width:30px' %> user(s) <%= submit_tag 'Do it now!' %>
24
23
  <% end %>
25
24
  <% end %>
26
25
 
27
- <%= osu_section_block "Login as an existing user" do %>
26
+ <%= osu.section_block "Login as an existing user" do %>
28
27
 
29
28
  <%= render 'openstax/connect/users/action_search', action_search_path: dev_users_search_path %>
30
29
 
31
- <% end %>
30
+ <% end %>
@@ -1,7 +1,7 @@
1
1
 
2
2
  <%= render template: 'openstax/connect/users/action_search',
3
3
  locals: {
4
- users: @results[:users],
4
+ users: @handler_result.outputs[:users],
5
5
  list: OpenStax::Connect::ActionList.new(
6
6
  headings: ['First Name', 'Last Name', 'Username', ''],
7
7
  widths: ['25%', '25%', '25%', '25%'],
@@ -0,0 +1 @@
1
+ require 'lev'
@@ -2,42 +2,68 @@ class ActionController::Base
2
2
  # References:
3
3
  # http://railscasts.com/episodes/356-dangers-of-session-hijacking
4
4
 
5
- # Always return an object
5
+ # Returns the current app user
6
6
  def current_user
7
- if !request.ssl? || cookies.signed[:secure_user_id] == "secure#{session[:user_id]}"
8
- @current_user ||= AnonymousUser.instance
9
-
10
- if @current_user.is_anonymous? && session[:user_id]
11
- # Use current_user= to clear out bad state if any
12
- self.current_user = User.where(id: session[:user_id]).first
13
- end
7
+ current_connect_user
8
+ @current_app_user
9
+ end
14
10
 
15
- @current_user
11
+ # Quasi "private" method that returns the current connect user, refreshing it if needed
12
+ def current_connect_user
13
+ if request.ssl? && cookies.signed[:secure_user_id] != "secure#{session[:user_id]}"
14
+ sign_out! # hijacked
15
+ else
16
+ @current_connect_user ||= OpenStax::Connect::User.anonymous
17
+ connect_sign_in(OpenStax::Connect::User.where(id: session[:user_id]).first) \
18
+ if @current_connect_user.is_anonymous? && session[:user_id]
16
19
  end
17
- end
20
+
21
+ @current_connect_user
22
+ end
18
23
 
24
+ # Sets (signs in) the provided app user.
19
25
  def current_user=(user)
20
- @current_user = user || AnonymousUser.instance
21
- if user.is_anonymous?
26
+ self.current_connect_user = OpenStax::Connect.configuration.user_provider.app_user_to_connect_user(user)
27
+ @current_app_user
28
+ end
29
+
30
+ # Quasi "private" method that sets the current connect user, also updates the cache
31
+ # of the current app user.
32
+ def current_connect_user=(user)
33
+ @current_connect_user = user || OpenStax::Connect::User.anonymous
34
+ if @current_connect_user.is_anonymous?
22
35
  session[:user_id] = nil
23
36
  cookies.delete(:secure_user_id)
24
37
  else
25
- session[:user_id] = user.id
26
- cookies.signed[:secure_user_id] = {secure: true, value: "secure#{user.id}"}
38
+ session[:user_id] = @current_connect_user.id
39
+ cookies.signed[:secure_user_id] = {secure: true, value: "secure#{@current_connect_user.id}"}
27
40
  end
28
- @current_user
41
+ @current_app_user = OpenStax::Connect.configuration.user_provider.connect_user_to_app_user(@current_connect_user)
42
+ @current_connect_user
29
43
  end
30
44
 
45
+ # Signs in the given app user
31
46
  def sign_in(user)
32
47
  self.current_user = user
33
48
  end
34
49
 
50
+ def connect_sign_in(user)
51
+ self.current_connect_user = user
52
+ end
53
+
54
+ # Signs out the user
35
55
  def sign_out!
36
- self.current_user = AnonymousUser.instance
56
+ self.current_connect_user = OpenStax::Connect::User.anonymous
37
57
  end
38
58
 
59
+ # Returns true iff there is a user signed in
39
60
  def signed_in?
40
- !current_user.is_anonymous?
61
+ !current_connect_user.is_anonymous?
62
+ end
63
+
64
+ # Useful in before_filters
65
+ def authenticate_user!
66
+ redirect_to openstax_connect.login_path unless signed_in?
41
67
  end
42
68
 
43
69
  protected
@@ -0,0 +1,15 @@
1
+ class CreateOpenStaxConnectUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :openstax_connect_users do |t|
4
+ t.integer :openstax_uid
5
+ t.string :first_name
6
+ t.string :last_name
7
+ t.string :username
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :openstax_connect_users, :openstax_uid, :unique => true
13
+ add_index :openstax_connect_users, :username, :unique => true
14
+ end
15
+ end
@@ -11,11 +11,13 @@ module OmniAuth
11
11
  :authorize_url => "/oauth/authorize"
12
12
  }
13
13
 
14
- uid { raw_info["uid"] }
14
+ uid { raw_info["uid"] }
15
15
 
16
16
  info do
17
17
  {
18
- :username => raw_info["username"]
18
+ username: raw_info["username"],
19
+ first_name: raw_info["first_name"],
20
+ last_name: raw_info["last_name"]
19
21
  # and anything else you want to return to your API consumers
20
22
  }
21
23
  end
@@ -10,8 +10,9 @@ module OpenStax
10
10
  class Engine < ::Rails::Engine
11
11
  isolate_namespace OpenStax::Connect
12
12
 
13
- config.autoload_paths << File.expand_path("../../../app/algorithms", __FILE__)
13
+ config.autoload_paths << File.expand_path("../../../app/routines", __FILE__)
14
14
  config.autoload_paths << File.expand_path("../../../app/handlers", __FILE__)
15
+ config.autoload_paths << File.expand_path("../../../app/concerns", __FILE__)
15
16
 
16
17
  config.generators do |g|
17
18
  g.test_framework :rspec, :view_specs => false
@@ -0,0 +1,3 @@
1
+ module OpenStax::Connect
2
+ class SecurityTransgression < StandardError; end
3
+ end
@@ -0,0 +1,13 @@
1
+ module OpenStax::Connect
2
+ class UserProvider
3
+
4
+ def self.connect_user_to_app_user(connect_user)
5
+ connect_user
6
+ end
7
+
8
+ def self.app_user_to_connect_user(app_user)
9
+ app_user
10
+ end
11
+
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Connect
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,8 +1,10 @@
1
- require "openstax/connect/engine"
2
1
  require "openstax/connect/version"
2
+ require "openstax/connect/exceptions"
3
+ require "openstax/connect/engine"
3
4
  require "openstax/connect/utilities"
4
5
  require "openstax/connect/route_helper"
5
6
  require "openstax/connect/action_list"
7
+ require "openstax/connect/user_provider"
6
8
 
7
9
  module OpenStax
8
10
  module Connect
@@ -42,6 +44,44 @@ module OpenStax
42
44
  attr_accessor :default_errors_partial
43
45
  attr_accessor :default_errors_html_id
44
46
  attr_accessor :default_errors_added_trigger
47
+ attr_accessor :security_transgression_exception
48
+
49
+ # OpenStax Connect provides you with an OpenStax::Connect::User object. You can
50
+ # use this as your app's User object without modification, you can modify it to suit
51
+ # your app's needs (not recommended), or you can provide your own custom User object
52
+ # that references the OpenStax Connect User object.
53
+ #
54
+ # OpenStax Connect also provides you methods for getting and setting the current
55
+ # signed in user (current_user and current_user= methods). If you choose to create
56
+ # your own custom User object that references the User object provide by Connect,
57
+ # you can teach OpenStax Connect how to translate between your app's custom User
58
+ # object and OpenStax Connect's built-in User object.
59
+ #
60
+ # To do this, you need to set a "user_provider" in this configuration.
61
+ #
62
+ # config.user_provider = MyUserProvider
63
+ #
64
+ # The user_provider is a class that provides two class methods:
65
+ #
66
+ # def self.connect_user_to_app_user(connect_user)
67
+ # # converts the given connect user to an app user
68
+ # # if you want to cache the connect_user in the app user
69
+ # # this is the place to do it.
70
+ # # If no app user exists for this connect user, one should
71
+ # # be created.
72
+ # end
73
+ #
74
+ # def self.app_user_to_connect_user(app_user)
75
+ # # converts the given app user to a connect user
76
+ # end
77
+ #
78
+ # Connect users are never nil. When a user is signed out, the current connect user
79
+ # is an anonymous user (responding true is "is_anonymous?"). You can follow the same
80
+ # pattern in your app or you can use nil for the current user. Just remember to check
81
+ # the anonymous status of connect users when doing your connect <-> app translations.
82
+ #
83
+ # The default user_provider just uses OpenStax::Connect::User as the app user.
84
+ attr_accessor :user_provider
45
85
 
46
86
  def openstax_services_url=(url)
47
87
  url.gsub!(/https|http/,'https') if !(url =~ /localhost/)
@@ -58,6 +98,8 @@ module OpenStax
58
98
  @default_errors_partial = 'openstax/connect/shared/attention'
59
99
  @default_errors_html_id = 'openstax-connect-attention'
60
100
  @default_errors_added_trigger = 'openstax-connect-errors-added'
101
+ @security_transgression_exception = OpenStax::Connect::SecurityTransgression
102
+ @user_provider = OpenStax::Connect::UserProvider
61
103
  super
62
104
  end
63
105
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-19 00:00:00.000000000 Z
12
+ date: 2013-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 0.0.3
85
+ version: 2.0.1
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 0.0.3
93
+ version: 2.0.1
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: sqlite3
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,6 @@ executables: []
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
- - app/algorithms/openstax/connect/search_users.rb
134
133
  - app/assets/javascripts/openstax/connect/application.js
135
134
  - app/assets/javascripts/openstax/connect/sessions.js
136
135
  - app/assets/stylesheets/openstax/connect/application.css
@@ -138,7 +137,6 @@ files:
138
137
  - app/assets/stylesheets/openstax/connect/sessions.css
139
138
  - app/controllers/openstax/connect/application_controller.rb
140
139
  - app/controllers/openstax/connect/dev/dev_controller.rb
141
- - app/controllers/openstax/connect/dev/sessions_controller.rb
142
140
  - app/controllers/openstax/connect/dev/users_controller.rb
143
141
  - app/controllers/openstax/connect/sessions_controller.rb
144
142
  - app/handlers/openstax/connect/dev/users_create.rb
@@ -147,8 +145,8 @@ files:
147
145
  - app/handlers/openstax/connect/sessions_omniauth_authenticated.rb
148
146
  - app/helpers/openstax/connect/application_helper.rb
149
147
  - app/helpers/openstax/connect/sessions_helper.rb
150
- - app/models/anonymous_user.rb
151
- - app/models/user.rb
148
+ - app/models/openstax/connect/user.rb
149
+ - app/routines/openstax/connect/search_users.rb
152
150
  - app/views/layouts/openstax/connect/application.html.erb
153
151
  - app/views/openstax/connect/dev/users/index.html.erb
154
152
  - app/views/openstax/connect/dev/users/search.js.erb
@@ -159,14 +157,16 @@ files:
159
157
  - app/views/openstax/connect/users/_action_list.html.erb
160
158
  - app/views/openstax/connect/users/_action_search.html.erb
161
159
  - app/views/openstax/connect/users/action_search.js.erb
160
+ - config/initializers/01_requires.rb
162
161
  - config/initializers/02_extend_builtins.rb
163
162
  - config/routes.rb
164
- - db/migrate/20130729213800_create_users.rb
165
- - db/migrate/20130909215452_add_fields_to_user.rb
163
+ - db/migrate/20130729213800_create_openstax_connect_users.rb
166
164
  - lib/omniauth/strategies/openstax.rb
167
165
  - lib/openstax/connect/action_list.rb
168
166
  - lib/openstax/connect/engine.rb
167
+ - lib/openstax/connect/exceptions.rb
169
168
  - lib/openstax/connect/route_helper.rb
169
+ - lib/openstax/connect/user_provider.rb
170
170
  - lib/openstax/connect/utilities.rb
171
171
  - lib/openstax/connect/version.rb
172
172
  - lib/openstax_connect.rb
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  segments:
190
190
  - 0
191
- hash: 28024144982429715
191
+ hash: 2014906712606740384
192
192
  required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  segments:
199
199
  - 0
200
- hash: 28024144982429715
200
+ hash: 2014906712606740384
201
201
  requirements: []
202
202
  rubyforge_project:
203
203
  rubygems_version: 1.8.25
@@ -1,21 +0,0 @@
1
- module OpenStax
2
- module Connect
3
- module Dev
4
- class SessionsController < DevController
5
-
6
- # def new
7
-
8
- # end
9
-
10
- # def create; end
11
-
12
- # def search
13
- # handle_with(Dev::SessionsUserSearch,
14
- # params: params,
15
- # complete: lambda { render 'search' })
16
- # end
17
-
18
- end
19
- end
20
- end
21
- end
@@ -1,40 +0,0 @@
1
- require 'singleton'
2
-
3
- class AnonymousUser
4
- include Singleton
5
-
6
- def is_administrator?
7
- false
8
- end
9
-
10
- def is_anonymous?
11
- true
12
- end
13
-
14
- def id
15
- nil
16
- end
17
-
18
- # Necessary if an anonymous user ever runs into an Exception
19
- # or else the developer email doesn't work
20
- def username
21
- 'anonymous'
22
- end
23
-
24
- def first_name
25
- 'Guest User'
26
- end
27
-
28
- def last_name
29
- 'Guest User'
30
- end
31
-
32
- def name
33
- 'Guest User'
34
- end
35
-
36
- def openstax_uid
37
- nil
38
- end
39
-
40
- end
data/app/models/user.rb DELETED
@@ -1,21 +0,0 @@
1
- class User < ActiveRecord::Base
2
-
3
- validates :username, uniqueness: true
4
- validates :username, presence: true
5
- validates :openstax_uid, presence: true
6
- validates :first_name, presence: true
7
- validates :last_name, presence: true
8
-
9
- def is_administrator?
10
- self.is_administrator
11
- end
12
-
13
- def is_anonymous?
14
- false
15
- end
16
-
17
- def name
18
- "#{first_name} #{last_name}"
19
- end
20
-
21
- end
@@ -1,9 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- t.integer :openstax_uid
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- class AddFieldsToUser < ActiveRecord::Migration
2
- def change
3
- add_column :users, :first_name, :string
4
- add_column :users, :last_name, :string
5
- add_column :users, :username, :string
6
- add_column :users, :is_administrator, :boolean, :default => false
7
-
8
- add_index :users, :openstax_uid, :unique => true
9
- add_index :users, :username, :unique => true
10
- end
11
- end