anadea-identity 0.1.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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +174 -0
  4. data/Rakefile +10 -0
  5. data/app/assets/images/facebook.png +0 -0
  6. data/app/assets/images/google_oauth2.png +0 -0
  7. data/app/assets/images/twitter.png +0 -0
  8. data/app/controllers/identity/base_controller.rb +5 -0
  9. data/app/controllers/identity/omniauth_callbacks_controller.rb +24 -0
  10. data/app/controllers/identity/users_controller.rb +58 -0
  11. data/app/models/identity/role.rb +16 -0
  12. data/app/models/identity/user.rb +47 -0
  13. data/app/views/devise/confirmations/new.html.erb +23 -0
  14. data/app/views/devise/mailer/confirmation_instructions.html.erb +6 -0
  15. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  16. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  17. data/app/views/devise/passwords/edit.html.erb +28 -0
  18. data/app/views/devise/passwords/new.html.erb +21 -0
  19. data/app/views/devise/registrations/edit.html.erb +34 -0
  20. data/app/views/devise/registrations/new.html.erb +28 -0
  21. data/app/views/devise/sessions/new.html.erb +31 -0
  22. data/app/views/devise/shared/_links.erb +25 -0
  23. data/app/views/devise/unlocks/new.html.erb +20 -0
  24. data/app/views/identity/users/edit.html.erb +70 -0
  25. data/app/views/identity/users/index.html.erb +55 -0
  26. data/config/locales/ca.yml +59 -0
  27. data/config/locales/de.yml +110 -0
  28. data/config/locales/en.yml +111 -0
  29. data/config/locales/es-AR.yml +51 -0
  30. data/config/locales/es-ES.yml +59 -0
  31. data/config/locales/es.yml +51 -0
  32. data/config/locales/fr.yml +51 -0
  33. data/config/locales/hu.yml +59 -0
  34. data/config/locales/it.yml +51 -0
  35. data/config/locales/nl.yml +59 -0
  36. data/config/locales/pl.yml +57 -0
  37. data/config/locales/pt-BR.yml +51 -0
  38. data/config/locales/ru.yml +56 -0
  39. data/config/locales/tr.yml +51 -0
  40. data/config/locales/zh-CN.yml +57 -0
  41. data/config/locales/zh-TW.yml +57 -0
  42. data/config/routes.rb +5 -0
  43. data/db/migrate/20150402142437_devise_create_identity_users.rb +42 -0
  44. data/db/migrate/20150402152859_rolify_create_identity_roles.rb +19 -0
  45. data/lib/anadea/identity.rb +1 -0
  46. data/lib/generators/identity/locales_generator.rb +8 -0
  47. data/lib/generators/identity/views_generator.rb +8 -0
  48. data/lib/identity.rb +50 -0
  49. data/lib/identity/admin/user.rb +89 -0
  50. data/lib/identity/devise_config.rb +31 -0
  51. data/lib/identity/engine.rb +21 -0
  52. data/lib/identity/version.rb +3 -0
  53. data/lib/identity/view_helper.rb +22 -0
  54. data/lib/tasks/whoami_tasks.rake +4 -0
  55. metadata +157 -0
@@ -0,0 +1,89 @@
1
+ if defined?(ActiveAdmin)
2
+ ActiveAdmin.register Identity::User, as: "Users" do
3
+ permit_params :email, :password, :password_confirmation, role_ids: []
4
+
5
+ filter :email
6
+ filter :active
7
+ filter :roles
8
+ filter :current_sign_in_at
9
+ filter :created_at
10
+
11
+ scope :all
12
+ scope :active, default: true
13
+ scope Identity.admins_method
14
+
15
+ index do
16
+ selectable_column
17
+ id_column
18
+ column :active
19
+ column Identity.admin_role do |user|
20
+ status_tag user.send(Identity.admin_role) ? 'yes' : 'no'
21
+ end
22
+ column :email
23
+ column :roles do |user|
24
+ user.role_names
25
+ end
26
+ if Devise.mappings[:user].confirmable?
27
+ column :confirmed do |user|
28
+ status_tag user.confirmed_at ? 'yes' : 'no'
29
+ end
30
+ end
31
+ if Devise.mappings[:user].trackable?
32
+ column :current_sign_in_ip
33
+ column :current_sign_in_at
34
+ end
35
+ column :created_at
36
+ column :updated_at
37
+ actions
38
+ end
39
+
40
+ show do
41
+ attributes_table do
42
+ row :active do |user|
43
+ status_tag user.active? ? 'yes' : 'no'
44
+ end
45
+ row Identity.admin_role do |user|
46
+ status_tag user.send(Identity.admin_role) ? 'yes' : 'no'
47
+ end
48
+ row :email
49
+ row :roles do |user|
50
+ user.role_names
51
+ end
52
+ if Devise.mappings[:user].trackable?
53
+ row :sign_in_count
54
+ row :current_sign_in_ip
55
+ row :current_sign_in_at
56
+ row :last_sign_in_ip
57
+ row :last_sign_in_at
58
+ end
59
+
60
+ if Devise.mappings[:user].confirmable?
61
+ row :confirmed_at
62
+ end
63
+
64
+ row :created_at
65
+ row :updated_at
66
+ end
67
+ end
68
+
69
+ form do |f|
70
+ inputs 'Basic' do
71
+ input :email
72
+ input :password
73
+ input :password_confirmation
74
+ input :roles, as: :check_boxes
75
+ end
76
+ f.actions
77
+ end
78
+
79
+ controller do
80
+ def update
81
+ if params[:identity_user][:password].blank? && params[:identity_user][:password_confirmation].blank?
82
+ params[:identity_user].delete("password")
83
+ params[:identity_user].delete("password_confirmation")
84
+ end
85
+ super
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,31 @@
1
+ require 'devise'
2
+
3
+ Devise.setup do |config|
4
+ require 'devise/orm/active_record'
5
+ config.mailer_sender =
6
+ ENV.fetch('MAIL_FROM', 'please-set-me-as-env-mail-from@example.com')
7
+
8
+ config.case_insensitive_keys = [ :email ]
9
+ config.strip_whitespace_keys = [ :email ]
10
+ config.skip_session_storage = [:http_auth]
11
+ config.stretches = Rails.env.test? ? 1 : 10
12
+ config.default_scope = :user
13
+ config.sign_out_via = :get
14
+
15
+ config.parent_controller = 'Identity::BaseController'
16
+ # config.omniauth_path_prefix = '/identity/users/auth'
17
+
18
+ # ==> Configuration for :confirmable
19
+ config.allow_unconfirmed_access_for = 2.days
20
+ config.reconfirmable = true
21
+
22
+ # ==> Configuration for :rememberable
23
+ config.expire_all_remember_me_on_sign_out = true
24
+ config.extend_remember_period = true
25
+
26
+ # ==> Configuration for :validatable
27
+ config.password_length = 1..256
28
+
29
+ # ==> Configuration for :recoverable
30
+ config.reset_password_within = 6.hours
31
+ end
@@ -0,0 +1,21 @@
1
+ require "devise"
2
+ require_relative "./devise_config"
3
+
4
+ require "rolify"
5
+
6
+ require_relative "./view_helper"
7
+
8
+ require "kaminari"
9
+ Kaminari::Hooks.init
10
+
11
+ module Identity
12
+ class Engine < ::Rails::Engine
13
+ initializer 'identity-views' do |app|
14
+ ActionView::Base.include Identity::ViewHelper
15
+ end
16
+
17
+ initializer 'identity-admin' do |app|
18
+ ActiveAdmin.application.load_paths.unshift(File.dirname(__FILE__) + '/admin')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Identity
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ module Identity
2
+ module ViewHelper
3
+ def bootstrap_devise_error_messages!
4
+ return '' if resource.errors.empty?
5
+
6
+ messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
7
+ sentence = I18n.t('errors.messages.not_saved',
8
+ count: resource.errors.count,
9
+ resource: resource.class.model_name.human.downcase)
10
+
11
+ html = <<-HTML
12
+ <div class="alert alert-danger alert-block">
13
+ <button type="button" class="close" data-dismiss="alert">x</button>
14
+ <h5>#{sentence}</h4>
15
+ #{messages}
16
+ </div>
17
+ HTML
18
+
19
+ html.html_safe
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :identity do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anadea-identity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anadea team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.2.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
+ - !ruby/object:Gem::Dependency
34
+ name: devise
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.4.1
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.4.1
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rolify
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 4.0.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '5'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 4.0.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '5'
73
+ description: An authentication bootstrapper for your Rails application.
74
+ email:
75
+ - dmitriy.kiriyenko@anahoret.com
76
+ executables: []
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - MIT-LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - app/assets/images/facebook.png
84
+ - app/assets/images/google_oauth2.png
85
+ - app/assets/images/twitter.png
86
+ - app/controllers/identity/base_controller.rb
87
+ - app/controllers/identity/omniauth_callbacks_controller.rb
88
+ - app/controllers/identity/users_controller.rb
89
+ - app/models/identity/role.rb
90
+ - app/models/identity/user.rb
91
+ - app/views/devise/confirmations/new.html.erb
92
+ - app/views/devise/mailer/confirmation_instructions.html.erb
93
+ - app/views/devise/mailer/reset_password_instructions.html.erb
94
+ - app/views/devise/mailer/unlock_instructions.html.erb
95
+ - app/views/devise/passwords/edit.html.erb
96
+ - app/views/devise/passwords/new.html.erb
97
+ - app/views/devise/registrations/edit.html.erb
98
+ - app/views/devise/registrations/new.html.erb
99
+ - app/views/devise/sessions/new.html.erb
100
+ - app/views/devise/shared/_links.erb
101
+ - app/views/devise/unlocks/new.html.erb
102
+ - app/views/identity/users/edit.html.erb
103
+ - app/views/identity/users/index.html.erb
104
+ - config/locales/ca.yml
105
+ - config/locales/de.yml
106
+ - config/locales/en.yml
107
+ - config/locales/es-AR.yml
108
+ - config/locales/es-ES.yml
109
+ - config/locales/es.yml
110
+ - config/locales/fr.yml
111
+ - config/locales/hu.yml
112
+ - config/locales/it.yml
113
+ - config/locales/nl.yml
114
+ - config/locales/pl.yml
115
+ - config/locales/pt-BR.yml
116
+ - config/locales/ru.yml
117
+ - config/locales/tr.yml
118
+ - config/locales/zh-CN.yml
119
+ - config/locales/zh-TW.yml
120
+ - config/routes.rb
121
+ - db/migrate/20150402142437_devise_create_identity_users.rb
122
+ - db/migrate/20150402152859_rolify_create_identity_roles.rb
123
+ - lib/anadea/identity.rb
124
+ - lib/generators/identity/locales_generator.rb
125
+ - lib/generators/identity/views_generator.rb
126
+ - lib/identity.rb
127
+ - lib/identity/admin/user.rb
128
+ - lib/identity/devise_config.rb
129
+ - lib/identity/engine.rb
130
+ - lib/identity/version.rb
131
+ - lib/identity/view_helper.rb
132
+ - lib/tasks/whoami_tasks.rake
133
+ homepage: https://github.com/Anadea/identity
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.5
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Authentication boostrapper for Rails.
157
+ test_files: []