authem 2.0.0 → 2.0.1

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: 67a264031f3e96725f18dc7e77c427ebd4708716
4
- data.tar.gz: 09c0291510e6909b13ea9c5a3efa473e3054020b
3
+ metadata.gz: c768903ff4928e45f93a0df8fa1620a9485a8078
4
+ data.tar.gz: 2b9dca77151effe7aa26791163305660d31434bf
5
5
  SHA512:
6
- metadata.gz: 771d1413927363e3c2426d0cee8d28fabf08389ce16a4aa6eefd06c6da6499177213f271fbc5ef2c111e48a2433c9695c1747877a6bb1b32e15aca99e4f491b7
7
- data.tar.gz: 6e3adc3d207f865439888550c6aeb1d8f84f202e6a2ec31f132a23e4a254a218d5bd905a148309966e6917426cb89544cc4501c0208a81a955ab6ee7c198cf81
6
+ metadata.gz: cb8715fe07acad644f4784a006b80d308766811b6a9918b4ad3632a2bf6d491750e3941553afbd8001a396bfeb9a7b8db87e0f46cb81be72a005097635559c12
7
+ data.tar.gz: 6bd3bb132620135a416ddbe9202353ae9fd732d049843eb37b0b79b6bdfd425c3da0176f4e429868dc92e9d6bfa4583d29b829966aeb63bd21d47bd21d0cf621
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.2
1
+ ruby-2.1.3
data/.travis.yml CHANGED
@@ -2,5 +2,7 @@ gemfile:
2
2
  - gemfiles/rails_4.0.gemfile
3
3
  - gemfiles/rails_4.1.gemfile
4
4
  rvm:
5
+ - jruby-19mode
6
+ - 1.9.3
5
7
  - 2.0.0
6
8
  - 2.1.1
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem "appraisal"
5
5
  group :test do
6
6
  gem "rspec", "~> 3.0"
7
7
  gem "rake", "~> 10.3"
8
- gem "sqlite3"
8
+ gem "sqlite3", platform: :ruby
9
+ gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
9
10
  gem "pry"
10
11
  end
data/README.markdown CHANGED
@@ -17,14 +17,20 @@ Please see the Authem website for up-to-date documentation: http://authem.org
17
17
 
18
18
  ## Upgrading to 2.0
19
19
 
20
- - Specify the latest alpha release in your Gemfile: `gem 'authem', '2.0.0.alpha.3'`
20
+ - Run `bundle update authem` and make sure you are on the 2.0.x release.
21
21
  - Remove references to the old Authem::Config object.
22
22
  - Create the new sessions table with `rails g authem:session`.
23
23
  - Replace `include Authem::ControllerSupport` with `authem_for :user`.
24
- - Rename `signed_in?` to `user_signed_in? OR `alias_method :signed_in?, :user_signed_in?` in your controller.
24
+ - Rename `signed_in?` to `user_signed_in?` OR `alias_method :signed_in?, :user_signed_in?` in your controller.
25
25
  - Rename column `User#reset_password_token` to `User#password_reset_token` OR `alias_attribute :password_reset_token, :reset_password_token` in your `User` model.
26
26
  - Replace calls to `user#reset_password_token!` with `user#password_reset_token`. Tokens are now generated automatically and the bang method is deprecated.
27
27
  - Rename `sign_out` to `sign_out_user` OR `alias_method :sign_out, :sign_out_user`
28
28
  - If you were passing a remember flag as the second argument to `sign_in`, you need to provide an options hash instead. For example, `sign_in(user, params[:remember])` would become `sign_in(user, remember: params[:remember])`.
29
29
  - Blank email addresses will now produce the proper "can't be blank" validation message". Update your tests accordingly.
30
30
  - Email addresses are no longer automatically downcased when calling `find_by_email` on your model. You will need to downcase the value manually if you wish to retain this behavior.
31
+ - Specify what to do when authem denies access to a user by adding something like this to your ApplicationController.
32
+ ```
33
+ def deny_user_access
34
+ redirect_to :sign_in
35
+ end
36
+ ```
data/authem.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/paulelliott/authem"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.required_ruby_version = ">= 2.0.0"
16
+ spec.required_ruby_version = ">= 1.9.3"
17
17
 
18
18
  spec.files = `git ls-files`.split($/)
19
19
  spec.test_files = spec.files.grep("spec")
@@ -11,6 +11,7 @@ gem "protected_attributes"
11
11
  group :test do
12
12
  gem "rspec", "~> 3.0"
13
13
  gem "rake", "~> 10.3"
14
- gem "sqlite3"
14
+ gem "sqlite3", :platform => :ruby
15
+ gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
15
16
  gem "pry"
16
17
  end
@@ -10,6 +10,7 @@ gem "railties", "~> 4.0"
10
10
  group :test do
11
11
  gem "rspec", "~> 3.0"
12
12
  gem "rake", "~> 10.3"
13
- gem "sqlite3"
13
+ gem "sqlite3", :platform => :ruby
14
+ gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
14
15
  gem "pry"
15
16
  end
@@ -8,29 +8,29 @@ module Authem
8
8
  included{ class_attribute :authem_roles }
9
9
 
10
10
  module SessionManagementMethods
11
- def sign_in(model, **options)
11
+ def sign_in(model, options={})
12
12
  role = options.fetch(:as){ self.class.authem_role_for(model) }
13
13
  public_send "sign_in_#{role}", model, options
14
14
  end
15
15
 
16
- def sign_out(model, **options)
16
+ def sign_out(model, options={})
17
17
  role = options.fetch(:as){ self.class.authem_role_for(model) }
18
18
  public_send "sign_out_#{role}"
19
19
  end
20
20
 
21
- def clear_all_sessions_for(model, **options)
21
+ def clear_all_sessions_for(model, options={})
22
22
  role = options.fetch(:as){ self.class.authem_role_for(model) }
23
23
  public_send "clear_all_#{role}_sessions_for", model
24
24
  end
25
25
 
26
- def redirect_back_or_to(url, **options)
26
+ def redirect_back_or_to(url, options={})
27
27
  url = session.delete(:return_to_url) || url
28
28
  redirect_to url, options
29
29
  end
30
30
  end
31
31
 
32
32
  module ClassMethods
33
- def authem_for(role_name, **options)
33
+ def authem_for(role_name, options={})
34
34
  include SessionManagementMethods
35
35
  Authem::Role.new(self, role_name, options).setup!
36
36
  end
data/lib/authem/role.rb CHANGED
@@ -4,7 +4,7 @@ module Authem
4
4
  class Role
5
5
  attr_reader :controller, :name, :options
6
6
 
7
- METHODS = %i[current sign_in signed_in? require sign_out clear_for deny_access]
7
+ METHODS = %w[current sign_in signed_in? require sign_out clear_for deny_access].map(&:to_sym)
8
8
 
9
9
  METHODS.each do |method_name|
10
10
  define_method method_name do |controller, *args|
@@ -12,7 +12,7 @@ module Authem
12
12
  end
13
13
  end
14
14
 
15
- def initialize(controller, name, **options)
15
+ def initialize(controller, name, options={})
16
16
  @controller, @name, @options = controller, name.to_s, options
17
17
  end
18
18
 
@@ -44,7 +44,7 @@ module Authem
44
44
  end
45
45
 
46
46
  def setup_view_helpers
47
- controller.helper_method *%I[current_#{name} #{name}_signed_in?]
47
+ controller.helper_method *%W[current_#{name} #{name}_signed_in?].map(&:to_sym)
48
48
  end
49
49
 
50
50
  def define_controller_method(*args, &block)
@@ -52,9 +52,9 @@ module Authem
52
52
  end
53
53
 
54
54
  def method_mapping
55
- exposed_methods = %I[current_#{name} sign_in_#{name}
55
+ exposed_methods = %W[current_#{name} sign_in_#{name}
56
56
  #{name}_signed_in? require_#{name} sign_out_#{name}
57
- clear_all_#{name}_sessions_for deny_#{name}_access]
57
+ clear_all_#{name}_sessions_for deny_#{name}_access].map(&:to_sym)
58
58
 
59
59
  Hash[[METHODS, exposed_methods].transpose]
60
60
  end
@@ -19,7 +19,7 @@ module Authem
19
19
  end
20
20
  end
21
21
 
22
- def sign_in(record, **options)
22
+ def sign_in(record, options={})
23
23
  check_record! record
24
24
  ivar_set record
25
25
  auth_session = create_auth_session(record, options)
@@ -120,7 +120,7 @@ module Authem
120
120
  end
121
121
 
122
122
  # exposing private controller methods
123
- %i[cookies session redirect_to request].each do |method_name|
123
+ %w[cookies session redirect_to request].each do |method_name|
124
124
  define_method method_name do |*args|
125
125
  controller.send(method_name, *args)
126
126
  end
@@ -1,3 +1,3 @@
1
1
  module Authem
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
@@ -9,7 +9,7 @@ class CreateAuthemSessions < ActiveRecord::Migration
9
9
  t.timestamps
10
10
  end
11
11
 
12
- add_index :authem_sessions, %i[expires_at token], unique: true
13
- add_index :authem_sessions, %i[expires_at subject_type subject_id], name: 'index_authem_sessions_subject'
12
+ add_index :authem_sessions, %w[expires_at token], unique: true
13
+ add_index :authem_sessions, %w[expires_at subject_type subject_id], name: 'index_authem_sessions_subject'
14
14
  end
15
15
  end
data/spec/user_spec.rb CHANGED
@@ -7,11 +7,12 @@ describe Authem::User do
7
7
  include Authem::User
8
8
 
9
9
 
10
- def self.create(email: "joe@example.com", password: "password")
10
+ def self.create(opts={})
11
+ opts = {email: "joe@example.com", password: "password"}.merge(opts)
11
12
  super(
12
- email: email,
13
- password: password,
14
- password_confirmation: password
13
+ email: opts[:email],
14
+ password: opts[:password],
15
+ password_confirmation: opts[:password]
15
16
  )
16
17
  end
17
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authem
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Elliott
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-09 00:00:00.000000000 Z
12
+ date: 2014-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: 2.0.0
114
+ version: 1.9.3
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.4.1
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Authem authenticates them by email