anadea-identity 0.2.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d260b5181f5424ced746062bfccaebbb78b2d994
4
- data.tar.gz: e75f779744fdab3a0df14b1e8b9959773df385a9
3
+ metadata.gz: def097b4755e88a07d17eecba90fcd1c6b9d8a7c
4
+ data.tar.gz: 84fee48d01725a0c1af1f1909d9d79902f576d40
5
5
  SHA512:
6
- metadata.gz: c35d7a55308dc24360f1b8e20530d49f5d31113a7418447a0a9a48fa45fe5f453257d9b66cffd91fc686e0e75fc5412fd91ea8f0981c433500c41d475f753a06
7
- data.tar.gz: af1a7b36db1494d15e96fe2d24625325416f6e322c33a8d2ac0ff0f3bf3b3f6f8f2386b4d70fb272a204b93fbc768d27830d5268e8b20fdaa1ffd939aaaab005
6
+ metadata.gz: 1748897c4af3e599fe9d4139a99194b748746918d1bbc04eef4b16ab2c32e984a63c27cca498fa654e79272b2e394562fd398c8cf8a032e99f7a7378d8220f76
7
+ data.tar.gz: 4552d1ed458b5bfcedeeb8bb040243fb2feb6feddb7986a1af4198056a9fcbe6f1d253b76489f24ad1bc58ee20823e47b043167723a0d27536d66c952864faa1
data/README.md CHANGED
@@ -78,7 +78,8 @@ email/пароль/подтверждение пароля), восстанов
78
78
  прочего. По умолчанию используется главный макет вашего приложения –
79
79
  `"application"`.
80
80
 
81
- * `config.auth_routes` – если задать `false`, маршруты подключены не будут и вы
81
+ * `config.auth_routes` – позволяет передать опции для роутов Devise, подключаемых
82
+ приложением. Если указать `false`, маршруты подключены не будут и вы
82
83
  можете сами подключить их.
83
84
 
84
85
  Вы также можете использовать любые конфигурационные опции самого Devise.
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  Rails.application.routes.draw do
2
2
  if Identity.auth_routes
3
- devise_for :users,
4
- class_name: Identity.user_class_name,
5
- module: :devise,
6
- controllers: { omniauth_callbacks: "identity/omniauth_callbacks" }
3
+ devise_for :users, Identity.auth_routes.reverse_merge(
4
+ class_name: Identity.user_class_name,
5
+ module: :devise,
6
+ controllers: { omniauth_callbacks: "identity/omniauth_callbacks" }
7
+ )
7
8
  end
8
9
  end
data/lib/identity.rb CHANGED
@@ -14,14 +14,31 @@ module Identity
14
14
 
15
15
  mattr_accessor(:user_class_name) { "::User" }
16
16
  mattr_accessor(:layout) { 'application' }
17
- mattr_accessor(:auth_routes) { true }
17
+ mattr_accessor(:auth_routes) { {} }
18
18
 
19
19
  def self.user_class
20
20
  user_class_name.constantize
21
21
  end
22
22
 
23
+
23
24
  def self.setup
24
25
  yield self
26
+
27
+ unless Identity.user_class.is_a? Identity::Mixins::User
28
+ Identity.user_class.include(Identity::Mixins::User)
29
+ end
30
+
31
+ ActiveRecord::Base.class_eval do
32
+ class << self
33
+ def inherited_with_identity_model(child)
34
+ if child.name == Identity.user_class_name
35
+ child.include(Identity::Mixins::User)
36
+ end
37
+ inherited_without_identity_model(child)
38
+ end
39
+ alias_method_chain :inherited, :identity_model
40
+ end
41
+ end
25
42
  end
26
43
 
27
44
  def self.method_missing(name, *args, &block)
@@ -33,7 +50,7 @@ module Identity
33
50
  end
34
51
 
35
52
  def self.delegate_to_devise?(name)
36
- name.in? %w(omniauth) ||
53
+ name.in?(%w(omniauth)) ||
37
54
  name.ends_with?('=') && Devise.respond_to?(name)
38
55
  end
39
56
 
@@ -1,74 +1,72 @@
1
- if defined?(ActiveAdmin)
2
- ActiveAdmin.register Identity.user_class, as: "Users" do
3
- permit_params :email, :password, :password_confirmation
1
+ ActiveAdmin.register Identity.user_class, as: "Users" do
2
+ permit_params :email, :password, :password_confirmation
4
3
 
5
- filter :email
6
- filter :active
7
- filter :current_sign_in_at
8
- filter :created_at
4
+ filter :email
5
+ filter :active
6
+ filter :current_sign_in_at
7
+ filter :created_at
9
8
 
10
- scope :all
11
- scope :active, default: true
9
+ scope :all
10
+ scope :active, default: true
12
11
 
13
- index do
14
- selectable_column
15
- id_column
16
- column :active
17
- column :email
18
- if Devise.mappings[:user].confirmable?
19
- column :confirmed do |user|
20
- status_tag user.confirmed_at ? 'yes' : 'no'
21
- end
22
- end
23
- if Devise.mappings[:user].trackable?
24
- column :current_sign_in_ip
25
- column :current_sign_in_at
12
+ index do
13
+ selectable_column
14
+ id_column
15
+ column :active
16
+ column :email
17
+ if Devise.mappings[:user].confirmable?
18
+ column :confirmed do |user|
19
+ status_tag user.confirmed_at ? 'yes' : 'no'
26
20
  end
27
- column :created_at
28
- column :updated_at
29
- actions
30
21
  end
22
+ if Devise.mappings[:user].trackable?
23
+ column :current_sign_in_ip
24
+ column :current_sign_in_at
25
+ end
26
+ column :created_at
27
+ column :updated_at
28
+ actions
29
+ end
31
30
 
32
- show do
33
- attributes_table do
34
- row :active do |user|
35
- status_tag user.active? ? 'yes' : 'no'
36
- end
37
- row :email
38
- if Devise.mappings[:user].trackable?
39
- row :sign_in_count
40
- row :current_sign_in_ip
41
- row :current_sign_in_at
42
- row :last_sign_in_ip
43
- row :last_sign_in_at
44
- end
45
-
46
- if Devise.mappings[:user].confirmable?
47
- row :confirmed_at
48
- end
31
+ show do
32
+ attributes_table do
33
+ row :active do |user|
34
+ status_tag user.active? ? 'yes' : 'no'
35
+ end
36
+ row :email
37
+ if Devise.mappings[:user].trackable?
38
+ row :sign_in_count
39
+ row :current_sign_in_ip
40
+ row :current_sign_in_at
41
+ row :last_sign_in_ip
42
+ row :last_sign_in_at
43
+ end
49
44
 
50
- row :created_at
51
- row :updated_at
45
+ if Devise.mappings[:user].confirmable?
46
+ row :confirmed_at
52
47
  end
48
+
49
+ row :created_at
50
+ row :updated_at
53
51
  end
52
+ end
54
53
 
55
- form do |f|
56
- inputs 'Basic' do
57
- input :email
58
- input :password
59
- input :password_confirmation
60
- end
61
- f.actions
54
+ form do |f|
55
+ inputs 'Basic' do
56
+ input :email
57
+ input :password
58
+ input :password_confirmation
62
59
  end
60
+ f.actions
61
+ end
63
62
 
64
- controller do
65
- def update
66
- if params[:identity_user][:password].blank? && params[:identity_user][:password_confirmation].blank?
67
- params[:identity_user].delete("password")
68
- params[:identity_user].delete("password_confirmation")
69
- end
70
- super
63
+ controller do
64
+ def update
65
+ if params[:identity_user][:password].blank? && params[:identity_user][:password_confirmation].blank?
66
+ params[:identity_user].delete("password")
67
+ params[:identity_user].delete("password_confirmation")
71
68
  end
69
+ super
72
70
  end
73
71
  end
74
72
  end
@@ -10,12 +10,8 @@ module Identity
10
10
  end
11
11
 
12
12
  initializer "identity-admin" do |app|
13
- ActiveAdmin.application.load_paths.unshift(File.dirname(__FILE__) + "/admin")
14
- end
15
-
16
- initializer "identity-model" do
17
- unless Identity.user_class.is_a?(Identity::Mixins::User)
18
- Identity.user_class.include(Identity::Mixins::User)
13
+ if defined?(ActiveAdmin)
14
+ ActiveAdmin.application.load_paths.unshift(File.dirname(__FILE__) + "/admin")
19
15
  end
20
16
  end
21
17
  end
@@ -1,3 +1,3 @@
1
1
  module Identity
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anadea-identity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anadea team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.1
19
+ version: 3.2.6
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.2.1
29
+ version: 3.2.6
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'