genki-restful-authentication 1.1.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.
Files changed (46) hide show
  1. data/CHANGELOG +68 -0
  2. data/README.textile +224 -0
  3. data/Rakefile +32 -0
  4. data/TODO +15 -0
  5. data/generators/authenticated/USAGE +1 -0
  6. data/generators/authenticated/authenticated_generator.rb +478 -0
  7. data/generators/authenticated/lib/insert_routes.rb +54 -0
  8. data/generators/authenticated/templates/_model_partial.html.erb +8 -0
  9. data/generators/authenticated/templates/activation.erb +3 -0
  10. data/generators/authenticated/templates/authenticated_system.rb +189 -0
  11. data/generators/authenticated/templates/authenticated_test_helper.rb +22 -0
  12. data/generators/authenticated/templates/controller.rb +43 -0
  13. data/generators/authenticated/templates/helper.rb +2 -0
  14. data/generators/authenticated/templates/login.html.erb +16 -0
  15. data/generators/authenticated/templates/mailer.rb +25 -0
  16. data/generators/authenticated/templates/migration.rb +26 -0
  17. data/generators/authenticated/templates/model.rb +83 -0
  18. data/generators/authenticated/templates/model_controller.rb +85 -0
  19. data/generators/authenticated/templates/model_helper.rb +93 -0
  20. data/generators/authenticated/templates/model_helper_spec.rb +158 -0
  21. data/generators/authenticated/templates/observer.rb +11 -0
  22. data/generators/authenticated/templates/signup.html.erb +19 -0
  23. data/generators/authenticated/templates/signup_notification.erb +8 -0
  24. data/generators/authenticated/templates/site_keys.rb +38 -0
  25. data/generators/authenticated/templates/spec/controllers/access_control_spec.rb +90 -0
  26. data/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb +102 -0
  27. data/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb +139 -0
  28. data/generators/authenticated/templates/spec/controllers/users_controller_spec.rb +198 -0
  29. data/generators/authenticated/templates/spec/fixtures/users.yml +60 -0
  30. data/generators/authenticated/templates/spec/helpers/users_helper_spec.rb +141 -0
  31. data/generators/authenticated/templates/spec/models/user_spec.rb +290 -0
  32. data/generators/authenticated/templates/test/functional_test.rb +82 -0
  33. data/generators/authenticated/templates/test/mailer_test.rb +31 -0
  34. data/generators/authenticated/templates/test/model_functional_test.rb +93 -0
  35. data/generators/authenticated/templates/test/unit_test.rb +164 -0
  36. data/init.rb +1 -0
  37. data/lib/authentication.rb +40 -0
  38. data/lib/authentication/by_cookie_token.rb +82 -0
  39. data/lib/authentication/by_password.rb +64 -0
  40. data/lib/authorization.rb +14 -0
  41. data/lib/authorization/aasm_roles.rb +63 -0
  42. data/lib/authorization/stateful_roles.rb +62 -0
  43. data/lib/trustification.rb +14 -0
  44. data/lib/trustification/email_validation.rb +20 -0
  45. data/rails/init.rb +3 -0
  46. metadata +108 -0
@@ -0,0 +1,14 @@
1
+ module Authorization
2
+ def self.included(recipient)
3
+ recipient.extend(ModelClassMethods)
4
+ recipient.class_eval do
5
+ include ModelInstanceMethods
6
+ end
7
+ end
8
+
9
+ module ModelClassMethods
10
+ end # class methods
11
+
12
+ module ModelInstanceMethods
13
+ end # instance methods
14
+ end
@@ -0,0 +1,63 @@
1
+ module Authorization
2
+ module AasmRoles
3
+ unless Object.constants.include? "STATEFUL_ROLES_CONSTANTS_DEFINED"
4
+ STATEFUL_ROLES_CONSTANTS_DEFINED = true # sorry for the C idiom
5
+ end
6
+
7
+ def self.included( recipient )
8
+ recipient.extend( StatefulRolesClassMethods )
9
+ recipient.class_eval do
10
+ include StatefulRolesInstanceMethods
11
+ include AASM
12
+ aasm_column :state
13
+ aasm_initial_state :initial => :pending
14
+ aasm_state :passive
15
+ aasm_state :pending, :enter => :make_activation_code
16
+ aasm_state :active, :enter => :do_activate
17
+ aasm_state :suspended
18
+ aasm_state :deleted, :enter => :do_delete
19
+
20
+ aasm_event :register do
21
+ transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
22
+ end
23
+
24
+ aasm_event :activate do
25
+ transitions :from => :pending, :to => :active
26
+ end
27
+
28
+ aasm_event :suspend do
29
+ transitions :from => [:passive, :pending, :active], :to => :suspended
30
+ end
31
+
32
+ aasm_event :delete do
33
+ transitions :from => [:passive, :pending, :active, :suspended], :to => :deleted
34
+ end
35
+
36
+ aasm_event :unsuspend do
37
+ transitions :from => :suspended, :to => :active, :guard => Proc.new {|u| !u.activated_at.blank? }
38
+ transitions :from => :suspended, :to => :pending, :guard => Proc.new {|u| !u.activation_code.blank? }
39
+ transitions :from => :suspended, :to => :passive
40
+ end
41
+ end
42
+ end
43
+
44
+ module StatefulRolesClassMethods
45
+ end # class methods
46
+
47
+ module StatefulRolesInstanceMethods
48
+ # Returns true if the user has just been activated.
49
+ def recently_activated?
50
+ @activated
51
+ end
52
+ def do_delete
53
+ self.deleted_at = Time.now.utc
54
+ end
55
+
56
+ def do_activate
57
+ @activated = true
58
+ self.activated_at = Time.now.utc
59
+ self.deleted_at = self.activation_code = nil
60
+ end
61
+ end # instance methods
62
+ end
63
+ end
@@ -0,0 +1,62 @@
1
+ module Authorization
2
+ module StatefulRoles
3
+ unless Object.constants.include? "STATEFUL_ROLES_CONSTANTS_DEFINED"
4
+ STATEFUL_ROLES_CONSTANTS_DEFINED = true # sorry for the C idiom
5
+ end
6
+
7
+ def self.included( recipient )
8
+ recipient.extend( StatefulRolesClassMethods )
9
+ recipient.class_eval do
10
+ include StatefulRolesInstanceMethods
11
+
12
+ acts_as_state_machine :initial => :pending
13
+ state :passive
14
+ state :pending, :enter => :make_activation_code
15
+ state :active, :enter => :do_activate
16
+ state :suspended
17
+ state :deleted, :enter => :do_delete
18
+
19
+ event :register do
20
+ transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
21
+ end
22
+
23
+ event :activate do
24
+ transitions :from => :pending, :to => :active
25
+ end
26
+
27
+ event :suspend do
28
+ transitions :from => [:passive, :pending, :active], :to => :suspended
29
+ end
30
+
31
+ event :delete do
32
+ transitions :from => [:passive, :pending, :active, :suspended], :to => :deleted
33
+ end
34
+
35
+ event :unsuspend do
36
+ transitions :from => :suspended, :to => :active, :guard => Proc.new {|u| !u.activated_at.blank? }
37
+ transitions :from => :suspended, :to => :pending, :guard => Proc.new {|u| !u.activation_code.blank? }
38
+ transitions :from => :suspended, :to => :passive
39
+ end
40
+ end
41
+ end
42
+
43
+ module StatefulRolesClassMethods
44
+ end # class methods
45
+
46
+ module StatefulRolesInstanceMethods
47
+ # Returns true if the user has just been activated.
48
+ def recently_activated?
49
+ @activated
50
+ end
51
+ def do_delete
52
+ self.deleted_at = Time.now.utc
53
+ end
54
+
55
+ def do_activate
56
+ @activated = true
57
+ self.activated_at = Time.now.utc
58
+ self.deleted_at = self.activation_code = nil
59
+ end
60
+ end # instance methods
61
+ end
62
+ end
@@ -0,0 +1,14 @@
1
+ module Trustification
2
+ def self.included(recipient)
3
+ recipient.extend(ModelClassMethods)
4
+ recipient.class_eval do
5
+ include ModelInstanceMethods
6
+ end
7
+ end
8
+
9
+ module ModelClassMethods
10
+ end # class methods
11
+
12
+ module ModelInstanceMethods
13
+ end # instance methods
14
+ end
@@ -0,0 +1,20 @@
1
+ module Trustification
2
+ module EmailValidation
3
+ unless Object.constants.include? "CONSTANTS_DEFINED"
4
+ CONSTANTS_DEFINED = true # sorry for the C idiom
5
+ end
6
+
7
+ def self.included(recipient)
8
+ recipient.extend(ClassMethods)
9
+ recipient.class_eval do
10
+ include InstanceMethods
11
+ end
12
+ end
13
+
14
+ module ClassMethods
15
+ end # class methods
16
+
17
+ module InstanceMethods
18
+ end # instance methods
19
+ end
20
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "authentication")
2
+ require File.join(File.dirname(__FILE__), "..", "lib", "authentication", "by_password")
3
+ require File.join(File.dirname(__FILE__), "..", "lib", "authentication", "by_cookie_token")
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genki-restful-authentication
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: ruby
6
+ authors:
7
+ - RailsJedi
8
+ - Rick Olson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-07-04 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 2.1.0
25
+ version:
26
+ description: This widely-used plugin provides a foundation for securely managing user.
27
+ email: railsjedi@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README.textile
34
+ files:
35
+ - CHANGELOG
36
+ - README.textile
37
+ - Rakefile
38
+ - TODO
39
+ - generators/authenticated/authenticated_generator.rb
40
+ - generators/authenticated/lib/insert_routes.rb
41
+ - generators/authenticated/templates/_model_partial.html.erb
42
+ - generators/authenticated/templates/activation.erb
43
+ - generators/authenticated/templates/authenticated_system.rb
44
+ - generators/authenticated/templates/authenticated_test_helper.rb
45
+ - generators/authenticated/templates/controller.rb
46
+ - generators/authenticated/templates/helper.rb
47
+ - generators/authenticated/templates/login.html.erb
48
+ - generators/authenticated/templates/mailer.rb
49
+ - generators/authenticated/templates/migration.rb
50
+ - generators/authenticated/templates/model.rb
51
+ - generators/authenticated/templates/model_controller.rb
52
+ - generators/authenticated/templates/model_helper.rb
53
+ - generators/authenticated/templates/model_helper_spec.rb
54
+ - generators/authenticated/templates/observer.rb
55
+ - generators/authenticated/templates/signup.html.erb
56
+ - generators/authenticated/templates/signup_notification.erb
57
+ - generators/authenticated/templates/site_keys.rb
58
+ - generators/authenticated/templates/spec/controllers/access_control_spec.rb
59
+ - generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb
60
+ - generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb
61
+ - generators/authenticated/templates/spec/controllers/users_controller_spec.rb
62
+ - generators/authenticated/templates/spec/fixtures/users.yml
63
+ - generators/authenticated/templates/spec/helpers/users_helper_spec.rb
64
+ - generators/authenticated/templates/spec/models/user_spec.rb
65
+ - generators/authenticated/templates/test/functional_test.rb
66
+ - generators/authenticated/templates/test/mailer_test.rb
67
+ - generators/authenticated/templates/test/model_functional_test.rb
68
+ - generators/authenticated/templates/test/unit_test.rb
69
+ - generators/authenticated/USAGE
70
+ - init.rb
71
+ - lib/authentication/by_cookie_token.rb
72
+ - lib/authentication/by_password.rb
73
+ - lib/authentication.rb
74
+ - lib/authorization/aasm_roles.rb
75
+ - lib/authorization/stateful_roles.rb
76
+ - lib/authorization.rb
77
+ - lib/trustification/email_validation.rb
78
+ - lib/trustification.rb
79
+ - rails/init.rb
80
+ has_rdoc: true
81
+ homepage: http://github.com/technoweenie/restful-authentication
82
+ post_install_message:
83
+ rdoc_options:
84
+ - --main
85
+ - README.textile
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.2.0
104
+ signing_key:
105
+ specification_version: 2
106
+ summary: Generates code for user login and authentication
107
+ test_files: []
108
+