authie 1.0.0 → 1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a723ac0bdb1ef36ed3084611c603fc5e17d3b65a
|
4
|
+
data.tar.gz: ca93a21ef49d797fd9aa69eb97b596a8f3e5bbd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe7a982ff92db20e736ae166eaefe30398bbd0e5cf2ac863bc1ceef0a4f0d092a1a176cb21b6c06b76aa42d9918eb654f6904bceaa65a1172587d13ac7a6b829
|
7
|
+
data.tar.gz: 728eb60de7c26c260c55144d4bed89a8794f57b642daefcd5412c79173f2d93a695364281e4a724cacca3e44355706ece8a919799e08f6ed6d660f8c82f3ecee
|
data/lib/authie/config.rb
CHANGED
@@ -10,12 +10,7 @@ module Authie
|
|
10
10
|
@persistent_session_length || 2.months
|
11
11
|
end
|
12
12
|
attr_writer :persistent_session_length
|
13
|
-
|
14
|
-
def user_model_class_name
|
15
|
-
@user_model_class_name || 'User'
|
16
|
-
end
|
17
|
-
attr_writer :user_model_class_name
|
18
|
-
|
13
|
+
|
19
14
|
end
|
20
15
|
|
21
16
|
def self.config
|
@@ -3,16 +3,25 @@ module Authie
|
|
3
3
|
|
4
4
|
def self.included(base)
|
5
5
|
base.helper_method :logged_in?, :current_user, :auth_session
|
6
|
-
base.before_filter :set_browser_id
|
6
|
+
base.before_filter :set_browser_id, :touch_auth_session
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
11
|
# Set a random browser ID for this browser.
|
12
|
-
# TODO: check that this is unique before setting it.
|
13
12
|
def set_browser_id
|
14
|
-
|
15
|
-
|
13
|
+
until cookies[:browser_id]
|
14
|
+
proposed_browser_id = SecureRandom.uuid
|
15
|
+
unless Session.where(:browser_id => proposed_browser_id).exists?
|
16
|
+
cookies[:browser_id] = {:value => proposed_browser_id, :expires => 20.years.from_now}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Touch the auth session on each request if logged in
|
22
|
+
def touch_auth_session
|
23
|
+
if logged_in?
|
24
|
+
auth_session.touch!
|
16
25
|
end
|
17
26
|
end
|
18
27
|
|
@@ -23,7 +32,7 @@ module Authie
|
|
23
32
|
|
24
33
|
# Set the currently logged in user
|
25
34
|
def current_user=(user)
|
26
|
-
if user
|
35
|
+
if user
|
27
36
|
unless logged_in?
|
28
37
|
@auth_session = Session.start(self, :user => user)
|
29
38
|
end
|
data/lib/authie/session.rb
CHANGED
@@ -10,7 +10,7 @@ module Authie
|
|
10
10
|
self.table_name = "authie_sessions"
|
11
11
|
|
12
12
|
# Relationships
|
13
|
-
belongs_to :user, :
|
13
|
+
belongs_to :user, :polymorphic => true
|
14
14
|
|
15
15
|
# Scopes
|
16
16
|
scope :active, -> { where(:active => true) }
|
data/lib/authie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Rails library for storing user sessions in a backend database
|
14
14
|
email:
|
@@ -18,6 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- db/migrate/20141012174250_create_authie_sessions.rb
|
21
|
+
- db/migrate/20141013115205_add_indexes_to_authie_sessions.rb
|
21
22
|
- lib/authie.rb
|
22
23
|
- lib/authie/config.rb
|
23
24
|
- lib/authie/controller_extension.rb
|