challah 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07cf70b1d4f4fe8cdfe785486b5864e90bc7f1f8
4
- data.tar.gz: d88604a025baf60b9284b957fa61151eb733c7ad
3
+ metadata.gz: f268cefe7d4d7ca73cf6b0631742de957ae0df84
4
+ data.tar.gz: 7e02e9a1e73e556191f0c67cebac024f72ceeb73
5
5
  SHA512:
6
- metadata.gz: 72d5615ce473dbbb4184b68a7e6a7b083e6f1d14d36cdb86590f325f7d9e4ee18294a9c8ac5f392f6374a8c68820b154697ff7e4b0881cb0e577f643f272f91b
7
- data.tar.gz: b0e24a5cf9082dc68b275b8a3f1a62422a149ce441362cd29b2ae4bb6a4cb748215c814ec202a26fd94a5068692c69973bea3b291a30ac7ac5b7d74754871a87
6
+ metadata.gz: d5101a14894aaca68f0e2bffe587f162cfe580a6c21d11937bab56d7eb4d242ae851750983e5081dfadfb9368fe861350d6f5288b00fd111251d64547a68a9aa
7
+ data.tar.gz: d5e4b7739526b89b43fe970256a54b1cf3a12c308a311f741944331fadde99ecd944689c7faa8c4156415e74ca121eecf495be06a7e4cbb5d5bedfbd1240cae3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## Challah 1.4
2
+
3
+ * Rails 5 support.
4
+ * Changed `users.active` boolean column to `users.status` enum with `active` as one of the options.
5
+ * Update sign-in page default bootstrap styles
6
+
7
+ ## Challah 1.3.3
8
+
9
+ * Fix Rails 4.2 "can't modify frozen hash ActiveSupport::HashWithIndifferentAccess" [PR #26](https://github.com/jdtornow/challah/pull/26) @stevenschobert
10
+
1
11
  ## Challah 1.3.2
2
12
 
3
13
  * Relax importing of highline in rake tasks to only include when in use
data/README.md CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  Challah (pronounced HAH-lah) is a simple Rails authentication gem that provides users a way to authenticate with your app. Most of the functionality within the gem lives within a Rails engine and tries to stay out of the way of your app.
6
6
 
7
- Challah doesnt provide any fancy controllers or views that clutter your app or force you to display information a certain way. That part is up to you. The functionality within Challah is designed to be a starting point for users and sign-ins you can tweak the rest to your apps needs.
7
+ Challah doesn't provide any fancy controllers or views that clutter your app or force you to display information a certain way. That part is up to you. The functionality within Challah is designed to be a starting point for users and sign-ins you can tweak the rest to your app's needs.
8
8
 
9
9
  ## Requirements
10
10
 
11
11
  * Ruby 2.1.2+
12
12
  * Bundler
13
- * Rails 4.2+
13
+ * Rails 5.0 (Recommended)
14
14
 
15
15
  ## Installation
16
16
 
@@ -24,50 +24,56 @@ gem "challah"
24
24
 
25
25
  Once the gem has been set up and installed, run the following command to set up the database migrations:
26
26
 
27
- rake challah:setup
27
+ ```bash
28
+ rails challah:setup
29
+ ```
28
30
 
29
- This will copy over the necessary migrations to your app, migrate the database and add some seed data. You will be prompted to add the first user as the last step in this process.
31
+ This will copy over the necessary migrations to your app and migrate the database. You will be prompted to add the first user as the last step in this process.
30
32
 
31
33
  ### Manual set up
32
34
 
33
35
  If you would prefer to handle these steps manually, you can do so by using these rake tasks instead:
34
36
 
35
- rake challah:setup:migrations
36
- rake db:migrate
37
- rake challah:setup:seeds
38
- rake challah:users:create
37
+ ```bash
38
+ rails challah:setup:migrations
39
+ rails challah:unpack:user
40
+ rails db:migrate
41
+ ```
39
42
 
40
43
  ### Creating users
41
44
 
42
- Since Challah doesnt provide any controller and views for users there are a few handy rake tasks you can use to create new records.
45
+ Since Challah doesn't provide any controller and views for users there are a few handy rake tasks you can use to create new records.
43
46
 
44
47
  Use the following task to create a new user:
45
48
 
46
- rake challah:users:create # => Creates a new User record
49
+ ```bash
50
+ # Creates a new User record
51
+ rails challah:users:create
52
+ ```
47
53
 
48
- ## Models
54
+ ## User Model
49
55
 
50
- Challah provides the core `User` model for your app, and a database migration to go along with it. You can customize the model to your app's specific needs, just leave the `challah_user` line intact.
56
+ Challah provides the core `User` model for your app, and a database migration to go along with it. You can do anything you want with the model, just leave the `Challah::Userable` concern intact to keep Challah's standard user methods included.
51
57
 
52
58
  A user is anyone that needs to be able to authenticate (sign in) to the application. Each user requires a first name, last name, email address, username, and password.
53
59
 
54
- By default a user is marked as active and is able to log in to your application. If the active status column is toggled to false, then this user is no longer able to log in. The active status column can be used as a soft-delete function for users.
60
+ By default a user is marked as "active" and is able to log in to your application. If the active status column is toggled to `inactive`, then this user is no longer able to log in. The active status column can be used as a soft-delete function for users.
55
61
 
56
62
  ## Checking for a current user
57
63
 
58
- The basic way to restrict functionality within your app is to require that someone authenticate (log in) before they can see it. From within your controllers and views you can call the `current_user?` method to determine if someone has authenticated. This method doesnt care about who the user is, or what it has access to, just that it has successfully authenticated and is a valid user.
64
+ The basic way to restrict functionality within your app is to require that someone authenticate (log in) before they can see it. From within your controllers and views you can call the `current_user?` method to determine if someone has authenticated. This method doesn't care about who the user is, or what it has access to, just that it has successfully authenticated and is a valid user.
59
65
 
60
66
  For example, restrict the second list item to only users that have logged in:
61
67
 
62
68
  ```erb
63
69
  <ul>
64
- <li><a href=”/”>Home</a></li>
70
+ <li><a href="/">Home</a></li>
65
71
 
66
72
  <% if current_user? %>
67
- <li><a href=”/secret-stuff”>Secret Stuff</a></li>
73
+ <li><a href="/secret-stuff">Secret Stuff</a></li>
68
74
  <% end %>
69
75
 
70
- <li><a href=”/public-stuff”>Not-so-secret Stuff</a></li>
76
+ <li><a href="/public-stuff">Not-so-secret Stuff</a></li>
71
77
  </ul>
72
78
  ```
73
79
 
@@ -104,41 +110,157 @@ end
104
110
 
105
111
  ## Default Routes
106
112
 
107
- By default, there are a few routes included with the Challah engine. These routes provide a basic method for a username- and password-based sign in page. These routes are:
113
+ By default, there are a few routes included with the Challah engine. These routes provide a basic method for a username and password sign in page. These routes are:
108
114
 
109
- GET /sign-in # => SessionsController#new
110
- POST /sign-in # => SessionsController#create
111
- GET /sign-out # => SessionsController#new
115
+ ```text
116
+ GET /sign-in # => SessionsController#new
117
+ POST /sign-in # => SessionsController#create
118
+ GET /sign-out # => SessionsController#new
119
+ ```
112
120
 
113
121
  Feel free to override the `SessionsController` with something more appropriate for your app.
114
122
 
115
- If youd prefer to set up your own sign in and sign out actions, you can skip the inclusion of the default routes by adding the following line to an initializer file in your app:
123
+ If you'd prefer to set up your own "sign in" and "sign out" actions, you can skip the inclusion of the default routes by adding the following line to an initializer file in your app:
116
124
 
117
- Challah.options[:skip_routes] = true
125
+ ```ruby
126
+ # in config/initializers/challah.rb
127
+ Challah.options[:skip_routes] = true
128
+ ```
118
129
 
119
130
  ## Sign In Form
120
131
 
121
- By default, the sign in form is tucked away within the Challah gem. If youd like to customize the markup or functionality of the sign in form, you can unpack it into your app by running:
132
+ By default, the sign in form is tucked away within the Challah gem. If you'd like to customize the markup or functionality of the sign in form, you can unpack it into your app by running:
122
133
 
123
- rake challah:unpack:views # => Copy the sign in view into your app
134
+ ```bash
135
+ # Copy the sign in view into your app
136
+ rails challah:unpack:views
137
+ ```
124
138
 
125
139
  If necessary, the sessions controller which handles creating new sessions and signing users out can also be unpacked into your app. This is really only recommended if you need to add some custom behavior or have advanced needs.
126
140
 
127
- rake challah:unpack:signin # => Copy the sessions controller into your app
141
+ ```bash
142
+ # Copy the sessions controller into your app
143
+ rails challah:unpack:signin
144
+ ```
145
+
146
+ ## ActionCable in Rails 5
147
+
148
+ Challah works well with securing your ActionCable channels since Rails 5. Here is a sample `ApplicationCable::Connection` file to secure connections to a valid signed-in user:
149
+
150
+ ```ruby
151
+ module ApplicationCable
152
+ class Connection < ActionCable::Connection::Base
153
+
154
+ identified_by :current_user
155
+
156
+ def connect
157
+ self.current_user = find_current_user
158
+ end
159
+
160
+ private
161
+
162
+ def find_current_user
163
+ if user = Challah::Session.find(request)
164
+ user
165
+ else
166
+ reject_unauthorized_connection
167
+ end
168
+ end
169
+
170
+ end
171
+ end
172
+ ```
173
+
174
+ ## Upgrading to Challah 1.4+
175
+
176
+ In Challah 1.4, the `active` boolean column changed to a `status` Rails enum with "active" as the default option. To upgrade a users table, use the following migration example:
177
+
178
+ ```bash
179
+ rails g migration ConvertUsersActiveToEnum
180
+ ```
181
+
182
+ ```ruby
183
+ class ConvertUsersActiveToEnum < ActiveRecord::Migration
184
+ def up
185
+ add_column :users, :status, :integer, default: 0
186
+
187
+ say_with_time "Converting users to status enum" do
188
+ User.where(active: false).update_all(status: User.statuses[:inactive])
189
+ end
190
+
191
+ remove_column :users, :active
192
+ end
193
+
194
+ def down
195
+ add_column :users, :active, :boolean, default: true
196
+
197
+ say_with_time "Converting users to active boolean" do
198
+ User.where(status: User.statuses[:inactive]).update_all(active: false)
199
+ end
200
+
201
+ remove_column :users, :status
202
+ end
203
+ end
204
+ ```
205
+
206
+ ## User Validations
207
+
208
+ By default, the `first_name`, `last_name`, and `email` fields are required on the user model. If you'd prefer to add your own validations and leave the defaults off, you can use the following option within an initializer:
209
+
210
+ ```ruby
211
+ # in config/initializers/challah.rb
212
+ Challah[:skip_user_validations] = true
213
+ ```
214
+
215
+ ## Authorization Model
216
+
217
+ The `Authorization` model can be used to store user credentials for a variety of different sources. By default, usernames and passwords are hashed and stored in this table.
218
+
219
+ In addition to the username/password, you can also use the authorizations table to store credentials or tokens for other services as well. For example, you could store a successful Facebook session using the following method:
220
+
221
+ ```ruby
222
+ Authorization.set({
223
+ # provider is just a key and can be anything to denote this service
224
+ provider: :facebook,
225
+
226
+ # the user's Facebook UID
227
+ uid: "000000",
228
+
229
+ # the user's Facebook-provided access token
230
+ token: "abc123",
231
+
232
+ # the user ID to link to this authorization
233
+ user_id: user.id,
234
+
235
+ # (optional, when this token expires)
236
+ expires_at: 60.minutes.from_now
237
+ })
238
+ ```
239
+
240
+ Then, to remove an authorization, just provide the user'd ID and the provider:
241
+
242
+ ```ruby
243
+ Authorization.del({
244
+ provider: :facebook,
245
+ user_id: user.id
246
+ })
247
+ ```
128
248
 
129
249
  ## Full documentation
130
250
 
131
251
  Documentation is available at: [http://rubydoc.info/gems/challah](http://rubydoc.info/gems/challah)
132
252
 
133
- ### Issues
253
+ ## Issues
134
254
 
135
255
  If you have any issues or find bugs running Challah, please [report them on Github](https://github.com/jdtornow/challah/issues). While most functions should be stable, Challah is still in its infancy and certain issues may be present.
136
256
 
137
- ### Testing
257
+ ## Testing
138
258
 
139
259
  Challah is fully tested using RSpec. To run the test suite, `bundle install` then run:
140
260
 
141
- rspec
261
+ ```bash
262
+ rspec
263
+ ```
142
264
 
143
265
  ## License
144
266
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.3
1
+ 1.4.0
@@ -3,13 +3,7 @@ if File.exist?(Rails.root.join("controllers/application_controller"))
3
3
  end
4
4
 
5
5
  class SessionsController < (defined?(ApplicationController) ? ApplicationController : ActionController::Base)
6
- if respond_to?(:before_action)
7
- # Rails >= 4.0
8
- before_action :destroy_session, except: :create
9
- else
10
- # Rails <= 3.2
11
- before_filter :destroy_session, except: :create
12
- end
6
+ before_action :destroy_session, except: :create
13
7
 
14
8
  # GET /login
15
9
  # GET /sign-in
data/app/models/user.rb CHANGED
@@ -1,9 +1,4 @@
1
1
  class User < ActiveRecord::Base
2
- # Uncomment this line if you are not using Rails 4. If you'd like to continue using
3
- # attr_accessible you can always install the strong_parameters gem from:
4
- # https://github.com/rails/strong_parameters
5
- #
6
- # attr_accessible :email, :first_name, :last_name, :password_confirmation, :password, :username
7
2
 
8
3
  # Set up Challah's User methods. Keep this as the first line of your model to include
9
4
  # all methods by default. You can override methods after this line as necessary.
@@ -12,4 +7,5 @@ class User < ActiveRecord::Base
12
7
  #
13
8
  # http://rubydoc.info/gems/challah
14
9
  include Challah::Userable
10
+
15
11
  end
@@ -1,33 +1,27 @@
1
- <div class="page-header">
2
- <h1>Sign In</h1>
3
- </div>
4
-
5
- <% if flash[:alert] %>
6
- <div class="alert alert-block alert-error">
7
- <%= flash[:alert] %>
8
- </div>
9
- <% end %>
10
-
11
- <%= form_for(@session, as: :session, url: signin_path, method: :post, html: { id: 'log-in-form' }) do |f| %>
1
+ <%= form_for @session, as: :session, url: signin_path, method: :post do |f| %>
12
2
  <div class="row">
13
- <div class="span6 form-horizontal">
14
- <div class="control-group">
15
- <%= f.label :username, t('.user_or_email'), class: 'control-label' %>
3
+ <div class="col-sm-12 col-md-4 col-md-offset-4">
4
+ <h2><%= t(".title") %></h2>
5
+
6
+ <hr />
16
7
 
17
- <div class="controls">
18
- <%= f.text_field :username, size: 40, maxlength: 200, class: 'span3' %>
8
+ <% if flash[:alert] %>
9
+ <div class="alert alert-danger">
10
+ <%= flash[:alert] %>
19
11
  </div>
20
- </div>
12
+ <% end %>
21
13
 
22
- <div class="control-group">
23
- <%= f.label :password, t('.password'), :class => 'control-label' %>
14
+ <div class="form-group">
15
+ <%= f.label :username, t(".user_or_email") %>
16
+ <%= f.text_field :username, size: 40, maxlength: 200, class: "form-control" %>
17
+ </div>
24
18
 
25
- <div class="controls">
26
- <%= f.password_field :password, size: 40, maxlength: 200, class: 'span3' %>
27
- </div>
19
+ <div class="form-group">
20
+ <%= f.label :password, t(".password") %>
21
+ <%= f.password_field :password, size: 40, maxlength: 200, class: "form-control" %>
28
22
  </div>
23
+
24
+ <%= f.submit t(".signin"), class: "btn btn-primary" %>
29
25
  </div>
30
26
  </div>
31
-
32
- <div class="form-actions"><%= f.submit t('.signin'), class: 'btn btn-primary' %></div>
33
- <% end %>
27
+ <% end %>
@@ -2,15 +2,16 @@ en:
2
2
  activerecord:
3
3
  errors:
4
4
  messages:
5
- invalid_email: 'is not a valid email address.'
6
- invalid_password: 'is not a valid password. Please enter at least 4 letters or numbers.'
7
- no_match_password: 'does not match the confirmation password.'
8
- invalid_key: 'is not valid. Please use only lower cased letters and underscores.'
5
+ invalid_email: "is not a valid email address."
6
+ invalid_password: "is not a valid password. Please enter at least 4 letters or numbers."
7
+ no_match_password: "does not match the confirmation password."
8
+ invalid_key: "is not valid. Please use only lower cased letters and underscores."
9
9
  sessions:
10
10
  new:
11
11
  user_or_email: "Username or email:"
12
12
  password: "Password:"
13
13
  login: "Log in"
14
14
  signin: "Sign in"
15
+ title: "Sign-in"
15
16
  create:
16
17
  failed_login: "There was a problem signing you in. Please check your username and password and try again."
@@ -8,7 +8,6 @@ class CreateUsers < ActiveRecord::Migration
8
8
  t.string :email_hash
9
9
  t.string :persistence_token
10
10
  t.string :api_key
11
- t.integer :role_id, default: 0 # Not used by default, install challah-rolls to utilize this
12
11
  t.datetime :last_session_at
13
12
  t.string :last_session_ip
14
13
  t.integer :session_count, default: 0
@@ -17,7 +16,7 @@ class CreateUsers < ActiveRecord::Migration
17
16
  t.integer :updated_by, default: 0
18
17
  t.datetime :created_at
19
18
  t.datetime :updated_at
20
- t.boolean :active, default: true
19
+ t.integer :status, default: 0 # defaults to :active
21
20
  t.timestamps null: true
22
21
  end
23
22
 
@@ -25,7 +24,6 @@ class CreateUsers < ActiveRecord::Migration
25
24
  add_index :users, :last_name
26
25
  add_index :users, :email
27
26
  add_index :users, :api_key
28
- add_index :users, :role_id
29
27
  end
30
28
 
31
29
  end
@@ -7,15 +7,34 @@ module Challah
7
7
  attr_reader :password_confirmation
8
8
  attr_reader :password_updated
9
9
 
10
+ if columns.map(&:name).include?("status")
11
+ enum status: %w( active inactive )
12
+ end
13
+
10
14
  before_save :ensure_user_tokens
11
15
  before_validation :normalize_user_email
12
16
  end
13
17
 
14
- # Returns true if this user is active, and should be able to log in. If
15
- # the active column is false, the user will not be able to authenticate
18
+ # Fallback to pre-enum active column (pre challah 1.4)
19
+ def active=(enabled)
20
+ if self.class.columns.map(&:name).include?("status")
21
+ self.status = (!!enabled ? :active : :inactive)
22
+ else
23
+ write_attribute(:active, !!enabled)
24
+ end
25
+ end
26
+
16
27
  def active?
17
- !!self.active
28
+ # enum-based status
29
+ if self.class.columns.map(&:name).include?("status")
30
+ read_attribute(:status).to_s == "active"
31
+
32
+ # support for non-enum status column (pre challah 1.4)
33
+ else
34
+ !!read_attribute(:active)
35
+ end
18
36
  end
37
+ alias_method :active, :active?
19
38
 
20
39
  # First name and last name together
21
40
  def name
@@ -31,7 +50,7 @@ module Challah
31
50
  #
32
51
  # Override this method if you need to check for a particular configuration on each page request.
33
52
  def valid_session?
34
- self.active?
53
+ active?
35
54
  end
36
55
 
37
56
  protected
@@ -2,14 +2,7 @@ module Challah
2
2
  module UserFindable
3
3
  extend ActiveSupport::Concern
4
4
 
5
- included do
6
- extend ClassMethods
7
- end
8
-
9
5
  module ClassMethods
10
- def active
11
- where(active: true)
12
- end
13
6
 
14
7
  # Find a user instance by username first, or email address if needed.
15
8
  # If no user is found matching, return nil
@@ -20,10 +13,6 @@ module Challah
20
13
  find_by_email(username_or_email) || find_by_authorization(username_or_email)
21
14
  end
22
15
 
23
- def inactive
24
- where.not(active: true)
25
- end
26
-
27
16
  protected
28
17
 
29
18
  def find_by_authorization(uid)
@@ -29,14 +29,8 @@ module Challah
29
29
  #
30
30
  # @see Controller::InstanceMethods#signin_required signin_required
31
31
  def restrict_to_authenticated(options = {})
32
- block = proc { |controller| controller.send(:signin_required) }
33
-
34
- if respond_to?(:before_action)
35
- # Rails >= 4.0
36
- before_action(options, &block)
37
- else
38
- # Rails <= 3.2
39
- before_filter(options, &block)
32
+ before_action(options) do |controller|
33
+ controller.send(:signin_required)
40
34
  end
41
35
  end
42
36
 
@@ -29,6 +29,11 @@ module Challah
29
29
  :signed_in?
30
30
  )
31
31
 
32
+ # Rails 5 API
33
+ if defined?(ActionController::API)
34
+ ActionController::API.send(:include, Challah::Controller)
35
+ end
36
+
32
37
  # Load any ActionController/Challah plugins
33
38
  Challah.plugins.values.each do |plugin|
34
39
  plugin.action_controller.each do |proc|
@@ -43,7 +48,6 @@ module Challah
43
48
  if defined?(ActiveRecord)
44
49
  Challah.options[:logger] = ActiveRecord::Base.logger
45
50
 
46
- ActiveRecord::Base.send(:include, Challah::ActiveRecordExtensions)
47
51
  ActiveRecord::Base.send(:include, Challah::Audit)
48
52
 
49
53
  # Load any ActiveRecord/Challah plugins
@@ -45,7 +45,13 @@ module Challah
45
45
  persistence_token, user_id = self.store.read
46
46
  return false if persistence_token.nil? or user_id.nil?
47
47
 
48
- store_user = user_model.unscoped.where(id: user_id).first
48
+ store_user = nil
49
+
50
+ begin
51
+ store_user = GlobalID::Locator.locate(user_id)
52
+ rescue ActiveRecord::RecordNotFound
53
+ nil
54
+ end
49
55
 
50
56
  if store_user and store_user.active? and store_user.persistence_token == persistence_token
51
57
  if store_user.valid_session?
@@ -70,7 +76,7 @@ module Challah
70
76
 
71
77
  # Id of the current user.
72
78
  def user_id
73
- @user_id ||= self.user ? self.user[:id] : nil
79
+ @user_id ||= self.user ? self.user.to_global_id : nil
74
80
  end
75
81
 
76
82
  def username
@@ -104,12 +110,22 @@ module Challah
104
110
 
105
111
  # Manually create a new Session
106
112
  def self.create(user_or_user_id, request = nil, params = nil, user_model = nil)
107
- user_model = Challah.user if user_model.nil?
108
-
109
- user_record = user_model === user_or_user_id ? user_or_user_id : user_model.find_by_id(user_or_user_id)
113
+ if user_model.nil?
114
+ user_model = Challah.user
115
+ end
110
116
 
111
117
  session = Session.new(request, params, user_model)
112
118
 
119
+ user_record = if user_model === user_or_user_id
120
+ user_or_user_id
121
+ else
122
+ begin
123
+ GlobalID::Locator.locate(user_or_user_id)
124
+ rescue ActiveRecord::RecordNotFound
125
+ nil
126
+ end
127
+ end
128
+
113
129
  if user_record and user_record.active?
114
130
  session.user = user_record
115
131
  session.persist = true
@@ -142,7 +158,7 @@ module Challah
142
158
  protected
143
159
 
144
160
  # Try and authenticate against the various auth techniques. If one
145
- # technique works, then just exist and make the session active.
161
+ # technique works, then just exit and make the session active.
146
162
  def authenticate!
147
163
  Challah.techniques.values.each do |klass|
148
164
  technique = klass.new(self)
data/lib/challah/test.rb CHANGED
@@ -12,14 +12,14 @@ module Challah
12
12
 
13
13
  def read
14
14
  if $challah_test_session
15
- return $challah_test_session.to_s.split(":")
15
+ return $challah_test_session.to_s.split("@")
16
16
  end
17
17
 
18
18
  nil
19
19
  end
20
20
 
21
21
  def save(token, user_id)
22
- $challah_test_session = "#{ token }:#{ user_id }"
22
+ $challah_test_session = "#{ token }@#{ user_id }"
23
23
  true
24
24
  end
25
25
  end
@@ -67,6 +67,7 @@ if defined?(RSpec)
67
67
  end
68
68
 
69
69
  config.include Challah::Testing, type: :controller
70
+ config.include Challah::Testing, type: :request
70
71
 
71
72
  end
72
73
  end
data/lib/tasks/setup.rake CHANGED
@@ -1,6 +1,6 @@
1
1
  namespace :challah do
2
2
  desc "Setup the challah gem within this rails app."
3
- task :setup => [ "challah:setup:migrations", "challah:unpack:user", "db:migrate", "challah:setup:seeds", "challah:users:create", "challah:banner" ]
3
+ task :setup => [ "challah:setup:migrations", "challah:unpack:user", "db:migrate", "challah:banner" ]
4
4
 
5
5
  task :banner do
6
6
  banner = <<-str
@@ -13,7 +13,9 @@ namespace :challah do
13
13
  And some new routes set up for /sign-in and /sign-out. You can use these
14
14
  for the built-in log in page or roll your own if you'd prefer.
15
15
 
16
- The user that you just created is ready to log in.
16
+ If you want to create a new user now, just run:
17
+
18
+ rails challah:users:create
17
19
 
18
20
  ==========================================================================
19
21
 
@@ -22,18 +24,10 @@ namespace :challah do
22
24
  puts banner
23
25
  end
24
26
 
25
- desc "Insert the default users, roles and permissions."
26
- task :seeds => [ "challah:setup:seeds" ]
27
-
28
27
  namespace :setup do
29
28
  task :migrations do
30
29
  puts "Copying migrations..."
31
- Rake::Task['challah_engine:install:migrations'].invoke
32
- end
33
-
34
- task :seeds => :environment do
35
- puts "Populating seed data..."
36
- Challah::Engine.load_seed
30
+ Rake::Task["challah_engine:install:migrations"].invoke
37
31
  end
38
32
  end
39
- end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: challah
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Tornow
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-06-03 00:00:00.000000000 Z
13
+ date: 2016-07-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -38,26 +38,26 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 4.0.0
41
+ version: 4.2.0
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 4.0.0
48
+ version: 4.2.0
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '10.3'
56
56
  type: :runtime
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '10.3'
63
63
  - !ruby/object:Gem::Dependency
@@ -137,7 +137,6 @@ files:
137
137
  - db/migrate/20120127150433_create_users.rb
138
138
  - db/migrate/20121116210759_create_authorizations.rb
139
139
  - lib/challah.rb
140
- - lib/challah/active_record_extensions.rb
141
140
  - lib/challah/audit.rb
142
141
  - lib/challah/authenticators.rb
143
142
  - lib/challah/authenticators/api_key.rb
@@ -185,15 +184,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
184
  requirements:
186
185
  - - ">="
187
186
  - !ruby/object:Gem::Version
188
- version: 1.9.2
187
+ version: 2.2.2
189
188
  required_rubygems_version: !ruby/object:Gem::Requirement
190
189
  requirements:
191
190
  - - ">="
192
191
  - !ruby/object:Gem::Version
193
- version: '0'
192
+ version: 1.8.11
194
193
  requirements: []
195
194
  rubyforge_project:
196
- rubygems_version: 2.2.2
195
+ rubygems_version: 2.5.1
197
196
  signing_key:
198
197
  specification_version: 4
199
198
  summary: Rails authentication and sessions
@@ -1,23 +0,0 @@
1
- module Challah
2
- # Included for backwards compatibility. These methods are deprecated
3
- # and will be removed in future versions
4
- module ActiveRecordExtensions
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- extend ClassMethods
9
- end
10
-
11
- module ClassMethods
12
- def challah_authorization
13
- ActiveSupport::Deprecation.warn("#{ self.to_s }.challah_authorization is deprecated and will be removed in future versions, use `include Challah::Authorizeable` instead")
14
- self.send(:include, Challah::Authorizeable)
15
- end
16
-
17
- def challah_user
18
- ActiveSupport::Deprecation.warn("#{ self.to_s }.challah_user is deprecated and will be removed in future versions, use `include Challah::Userable` instead")
19
- self.send(:include, Challah::Userable)
20
- end
21
- end
22
- end
23
- end