jt-rails-generator-user 1.0.5 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e6230983debe5609948a03131ef93bb252a4ba0
4
- data.tar.gz: 44dbec68d32e92386eec35dcb47ca7dc383742f6
3
+ metadata.gz: f34a1b854f33a7b750bbb2b710e9a919cf6c227d
4
+ data.tar.gz: c782887d8f0251e309c319ad0ae909b775ad9954
5
5
  SHA512:
6
- metadata.gz: 6391eb3347fbee4276e92f20cda23483a3bda94fddc2c399c8771288fefafa4b1068d744dfe1dd6c1f90708f47c4280b99d065909e345ceaba74dfe3c60aef4a
7
- data.tar.gz: 0e823ed91dd0d47d7d80ebf0fba0f242724176775ca46144ea085c341ed7a21f11fec629611ff321dfcb13bbefb934c09b1a092890c4728cbbedab05aa57b2f8
6
+ metadata.gz: b40630ccba57c63335052cb99dd3e7911c680e09190a31af490b7c55d67bc506ee5a74e4f36f837dad0808813f61935b067473b10620994d3def201622cdf390
7
+ data.tar.gz: 7c644a85299559db59c402b7c2e958ad8db494b216a90c49253bb61500718b1fe8689f9aea864dccb1f30b62b04529e72c164ea123218f1a438a2a58d7d4a336
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.summary = "Generate a scaffold for user authentication in Ruby On Rails"
4
4
  s.description = "JTRailsGeneratorUser is a generator for user authentication. You have the login and sign up page, password forgot feature."
5
5
  s.homepage = 'https://github.com/jonathantribouharet/jt-rails-generator-user'
6
- s.version = '1.0.5'
6
+ s.version = '1.0.6'
7
7
  s.files = `git ls-files`.split("\n")
8
8
  s.require_paths = ['lib']
9
9
  s.authors = ['Jonathan TRIBOUHARET']
@@ -7,6 +7,7 @@ module CurrentUser
7
7
 
8
8
  def set_current_user(user)
9
9
  session[:user_id] = user.id
10
+ user.increment_login_stats!(request.remote_ip)
10
11
  end
11
12
 
12
13
  def current_user
@@ -15,7 +15,7 @@ module UserAuthentication
15
15
 
16
16
  end
17
17
 
18
- module ClassMethods
18
+ class_methods do
19
19
 
20
20
  def authenticate(email, password)
21
21
  self.search_by_email_for_authentication(email).first.try(:authenticate, password)
@@ -27,4 +27,14 @@ module UserAuthentication
27
27
  self.email.downcase! if self.email
28
28
  end
29
29
 
30
+ def increment_login_stats!(remote_ip)
31
+ attributes = {
32
+ last_login_at: Time.now,
33
+ last_login_remote_ip: remote_ip,
34
+ login_count: (self.login_count || 0) + 1
35
+ }
36
+
37
+ self.update_columns(attributes)
38
+ end
39
+
30
40
  end
@@ -4,7 +4,7 @@ module Jt
4
4
  source_root File.expand_path("../templates", __FILE__)
5
5
 
6
6
  def create_initializer_file
7
- generate "migration", "CreateUsers", "email:string password_digest:string password_token:string"
7
+ generate "migration", "CreateUsers", "email:string password_digest:string password_token:string last_login_at:datetime last_login_remote_ip:string login_count:integer"
8
8
 
9
9
  directory 'controllers', 'app/controllers'
10
10
  directory 'mailers', 'app/mailers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jt-rails-generator-user
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan TRIBOUHARET
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: validates_email_format_of