devise_pg_authenticatable 0.1.0 → 0.2.0

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.
@@ -1,24 +1,31 @@
1
- Devise PG Authenticatable
2
- =================
1
+ = Devise PG Authenticatable
3
2
 
4
- Devise PG Authenticatable is a PostgreSQL based authentication strategy for the [Devise](http://github.com/plataformatec/devise) authentication framework. PG Authenticatable is replacement for module :database\_authenticatable from Devise. This module authenticate users against PostgreSQL system database.
3
+ Devise PG Authenticatable is a PostgreSQL based authentication strategy for the Devise[http://github.com/plataformatec/devise] authentication framework. PG Authenticatable is replacement for module database\_authenticatable from Devise. This module authenticate users against PostgreSQL system database.
5
4
 
6
5
  This module is based on Devise-Imapable and Devise-LDAP-ldap\_authenticatable.
7
6
 
8
- Requirements
9
- ------------
7
+ == Requirements
10
8
 
11
- - Rails 2.3.5
12
- - Devise 1.0.7
9
+ * Rails 2.3.5
10
+ * Devise 1.0.7
13
11
 
14
- Installation
15
- ------------
12
+ == Installation
16
13
 
17
- script/plugin install git://github.com/boblin/devise_pg_authenticatable.git
14
+ script/plugin install git://github.com/boblin/devise_pg_authenticatable.git
18
15
 
16
+ or
17
+
18
+ gem install devise_pg_authenticatable
19
19
 
20
- Setup
21
- -----
20
+
21
+ Your config/environment.rb file may looks like this:
22
+
23
+ config.gem 'devise', :version => '1.0.7'
24
+ config.gem 'devise_pg_authenticatable'
25
+
26
+
27
+
28
+ == Setup
22
29
 
23
30
  Once devise\_pg\_authenticatable is installed, all you need to do is setup the user model which includes a small addition to the model itself and to the schema.
24
31
 
@@ -32,7 +39,7 @@ and indexes (optional) :
32
39
 
33
40
  add_index :login, :unique => true
34
41
 
35
- and don’t forget to migrate :
42
+ and do not forget to migrate :
36
43
 
37
44
  rake db:migrate.
38
45
 
@@ -46,44 +53,39 @@ then the model :
46
53
  ...
47
54
  end
48
55
 
49
- and finally change the authentication key in the devise initializer :
56
+ and finally change the authentication key in the config/initializers/devise.rb :
50
57
 
51
58
  Devise.setup do |config|
52
- ...
53
- config.authentication_keys = [ :login ]
54
- ...
59
+ config.login_attribute = [ :login_name ] # default :login
55
60
  end
56
61
 
57
62
  I recommend using :rememberable, :trackable, :timeoutable as it gives a full feature set for logins.
58
63
 
59
- Usage
60
- -----
64
+ == Usage
61
65
 
62
66
  Devise PG Authenticatable works in replacement of Authenticatable,
63
67
  but because we have to change the authentication\_keys, you'll need to run:
64
68
 
65
69
  script/generate devise_views
66
70
 
67
- and customize your login pages to use :login, instead of :email.
71
+ and customize your login pages to use :login or your custom login_attribute , instead of :email.
68
72
 
69
- ------------------------------------------------------------
70
73
 
71
- **_Please Note_**
74
+ === Please Note
72
75
 
73
76
  This devise plugin has not been tested with Authenticatable enabled at the same time. This is meant as a drop in replacement for Authenticatable allowing for a semi single sign on approach.
74
77
 
75
78
 
76
- References
77
- ----------
79
+ == References
78
80
 
79
- * [Devise](http://github.com/plataformatec/devise)
80
- * [Warden](http://github.com/hassox/warden)
81
+ * http://github.com/plataformatec/devise
82
+ * http://github.com/hassox/warden
81
83
 
82
84
 
83
- TODO
84
- ----
85
+ == TODO
85
86
 
86
- - Tests
87
+ * tests
88
+ * allow users to change password
87
89
 
88
90
  Released under the MIT license
89
91
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -5,20 +5,20 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{devise_pg_authenticatable}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bohuslav Blin"]
12
- s.date = %q{2010-06-11}
12
+ s.date = %q{2010-06-14}
13
13
  s.description = %q{Devise PostgreSQL authentication module}
14
14
  s.email = %q{bohuslav@blin.cz}
15
15
  s.extra_rdoc_files = [
16
- "README.md"
16
+ "README.rdoc"
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
20
  "MIT-LICENSE",
21
- "README.md",
21
+ "README.rdoc",
22
22
  "Rakefile",
23
23
  "VERSION",
24
24
  "devise_pg_authenticatable.gemspec",
@@ -6,9 +6,9 @@ require 'devise_pg_authenticatable/pg_adapter'
6
6
  require 'devise_pg_authenticatable/routes'
7
7
 
8
8
  module Devise
9
- # database
10
- # mattr_accessor :pg_database
11
- # @@pg_database = nil
9
+ # login
10
+ mattr_accessor :login_attribute
11
+ @@login_attribute = "login"
12
12
  end
13
13
 
14
14
  # Add pg_authenticatable strategy to defaults.
@@ -23,28 +23,20 @@ module Devise
23
23
  end
24
24
 
25
25
  # Checks if a resource is valid upon authentication.
26
- def valid_pg_authentication?(password)
27
- Devise::PgAdapter.valid_credentials?(self.login, password)
26
+ def valid_pg_authentication?(login, password)
27
+ Devise::PgAdapter.valid_credentials?(login, password)
28
28
  end
29
29
 
30
30
  module ClassMethods
31
+ Devise::Models.config(self, :login_attribute)
31
32
  # Authenticate a user based on configured attribute keys. Returns the
32
33
  # authenticated user if it's valid or nil.
33
34
  def authenticate_with_pg(attributes={})
34
- return unless attributes[:login].present?
35
- conditions = attributes.slice(:login)
36
-
37
- unless conditions[:login]
38
- conditions[:login] = "#{conditions[:login]}"
39
- end
40
-
35
+ return unless attributes[login_attribute].present?
36
+ conditions = attributes.slice(login_attribute)
41
37
  resource = find_for_pg_authentication(conditions)
42
- # resource = new(conditions) if resource.nil?
43
-
44
- # resource = find_for_pg_authentication(conditions) || new(conditions)
45
-
46
38
 
47
- if resource.try(:valid_pg_authentication?, attributes[:password])
39
+ if resource.try(:valid_pg_authentication?, attributes[login_attribute], attributes[:password])
48
40
  resource.new_record? ? create(conditions) : resource
49
41
  end
50
42
  end
@@ -56,7 +48,7 @@ module Devise
56
48
  # namedscope to filter records while authenticating.
57
49
  # Example:
58
50
  #
59
- # def self.find_for_imap_authentication(conditions={})
51
+ # def self.find_for_pg_authentication(conditions={})
60
52
  # conditions[:active] = true
61
53
  # find(:first, :conditions => conditions)
62
54
  # end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bohuslav Blin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-11 00:00:00 +02:00
17
+ date: 2010-06-14 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -38,11 +38,11 @@ executables: []
38
38
  extensions: []
39
39
 
40
40
  extra_rdoc_files:
41
- - README.md
41
+ - README.rdoc
42
42
  files:
43
43
  - .gitignore
44
44
  - MIT-LICENSE
45
- - README.md
45
+ - README.rdoc
46
46
  - Rakefile
47
47
  - VERSION
48
48
  - devise_pg_authenticatable.gemspec