stupid_auth 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/stupid_auth/model.rb +10 -3
  2. metadata +3 -6
@@ -26,10 +26,12 @@ module StupidAuth
26
26
 
27
27
  # Search the login_field for the given value and
28
28
  # attempt to authenticate a found user with the given password
29
+ # set the logged in at timestamp
29
30
  def authenticate login, provided_password = nil
30
- finder = "find_by_#{ login_field }"
31
- user = self.send finder, login
32
- (user.present? and user.authenticated_by?provided_password) ? user : nil
31
+ user = self.send "find_by_#{ login_field }", login
32
+ return nil unless user.present? and user.authenticated_by? provided_password
33
+ user.send :set_logged_in_at!
34
+ user
33
35
  end
34
36
 
35
37
  end
@@ -51,6 +53,11 @@ module StupidAuth
51
53
 
52
54
  private
53
55
 
56
+ def set_logged_in_at!
57
+ return nil unless respond_to? :logged_in_at
58
+ update_attribute :logged_in_at, Time.zone.now
59
+ end
60
+
54
61
  # Hash the provided password and persist it, along with a salt
55
62
  def encrypt_password
56
63
  return true if password.blank?
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stupid_auth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 3
10
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
11
10
  platform: ruby
12
11
  authors:
13
12
  - Dev Fu!
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-30 00:00:00 -07:00
17
+ date: 2011-02-02 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
@@ -46,7 +45,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - ">="
48
47
  - !ruby/object:Gem::Version
49
- hash: 3
50
48
  segments:
51
49
  - 0
52
50
  version: "0"
@@ -55,7 +53,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
53
  requirements:
56
54
  - - ">="
57
55
  - !ruby/object:Gem::Version
58
- hash: 3
59
56
  segments:
60
57
  - 0
61
58
  version: "0"