authem 2.0.0 → 2.0.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/.ruby-version +1 -1
- data/.travis.yml +2 -0
- data/Gemfile +2 -1
- data/README.markdown +8 -2
- data/authem.gemspec +1 -1
- data/gemfiles/rails_4.0.gemfile +2 -1
- data/gemfiles/rails_4.1.gemfile +2 -1
- data/lib/authem/controller.rb +5 -5
- data/lib/authem/role.rb +5 -5
- data/lib/authem/support.rb +2 -2
- data/lib/authem/version.rb +1 -1
- data/lib/generators/authem/session/templates/create_sessions.rb +2 -2
- data/spec/user_spec.rb +5 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c768903ff4928e45f93a0df8fa1620a9485a8078
|
4
|
+
data.tar.gz: 2b9dca77151effe7aa26791163305660d31434bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb8715fe07acad644f4784a006b80d308766811b6a9918b4ad3632a2bf6d491750e3941553afbd8001a396bfeb9a7b8db87e0f46cb81be72a005097635559c12
|
7
|
+
data.tar.gz: 6bd3bb132620135a416ddbe9202353ae9fd732d049843eb37b0b79b6bdfd425c3da0176f4e429868dc92e9d6bfa4583d29b829966aeb63bd21d47bd21d0cf621
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.1.
|
1
|
+
ruby-2.1.3
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
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
|
-
-
|
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
|
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 = ">=
|
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")
|
data/gemfiles/rails_4.0.gemfile
CHANGED
data/gemfiles/rails_4.1.gemfile
CHANGED
data/lib/authem/controller.rb
CHANGED
@@ -8,29 +8,29 @@ module Authem
|
|
8
8
|
included{ class_attribute :authem_roles }
|
9
9
|
|
10
10
|
module SessionManagementMethods
|
11
|
-
def sign_in(model,
|
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,
|
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,
|
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,
|
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,
|
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 = %
|
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,
|
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 *%
|
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 = %
|
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
|
data/lib/authem/support.rb
CHANGED
@@ -19,7 +19,7 @@ module Authem
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def sign_in(record,
|
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
|
-
%
|
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
|
data/lib/authem/version.rb
CHANGED
@@ -9,7 +9,7 @@ class CreateAuthemSessions < ActiveRecord::Migration
|
|
9
9
|
t.timestamps
|
10
10
|
end
|
11
11
|
|
12
|
-
add_index :authem_sessions, %
|
13
|
-
add_index :authem_sessions, %
|
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(
|
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.
|
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-
|
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:
|
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.
|
122
|
+
rubygems_version: 2.4.1
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Authem authenticates them by email
|