anadea-identity 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b90fe456fe3459656452c7191052e3cf7b9e72bd
4
- data.tar.gz: 7942ef52f965589850dc1e2d9b1be489aaf96fac
3
+ metadata.gz: b5e7fe5d40f2bc8c0bd6bf9a41143d04b0b35eb1
4
+ data.tar.gz: 04c73a221ff0d77f1a327332e6fa0f616f7fa91c
5
5
  SHA512:
6
- metadata.gz: 351d14c0435915e9e1324bbca2b9e53dbcda6764044e16b8138de4d24e2ca44bbf7525e343623104243ab18a0145b38028e2d62a0cd27a7718373bd413f46b8a
7
- data.tar.gz: d072c2f56d804f4174305d38f4bc1bb3a412359b66a0d739e92742bd7f1a917a8f9d392e7d4c9c190eaa501c74cd81d60f3ed3ceeffe61e19571795de94ca112
6
+ metadata.gz: 7b4d5997ca0d6ae09a0db56e31dd1ad0783a676f8ad836af5bb85e1b8c57a80aa2ad8cb4d189e31c6e102c454bfe8144f98ccbf0bcc160d9cfd8bdfe3277e3e8
7
+ data.tar.gz: 07e4e5ff7b1b8bd419c2b6736b11456d20b12f3e5b58c7545a0a44e693e7b1db2c35ddaf160e95ffda1315cd84ad611b86d2692f30479ecbb7837363a2a445c7
data/README.md CHANGED
@@ -16,13 +16,13 @@ gem 'anadea-identity'
16
16
  $ bundle
17
17
  ```
18
18
 
19
- Сгенерируйте миграции:
19
+ Запустите генератор:
20
20
 
21
21
  ```console
22
- $ rake identity_engine:install:migrations
22
+ $ rails g identity:install User
23
23
  ```
24
24
 
25
- проверьте их и запустите:
25
+ проверьте миграцию и запустите:
26
26
 
27
27
  ```console
28
28
  $ rake db:migrate
@@ -39,36 +39,6 @@ $ rake db:migrate
39
39
  У вас работает логин (через форму email/пароль), регистрация (через форму
40
40
  email/пароль/подтверждение пароля), восстановление пароля и многое другое.
41
41
 
42
- ### Модель User
43
-
44
- Вызов `current_user` в контроллере вернёт `Identity::User`, соответствующий
45
- таблице `identity_users`. Не нужно добавлять в эту модель методы и не нужно
46
- добавлять в эту таблицу колонки, кроме тех, которые используются Devise или
47
- Identity. Эту модель следует считать публичным интерфейсом, предоставляеым гемом.
48
-
49
- Рекомендуется заводить модели типа `Profile` или `Account` которые будут
50
- "принадлежать" (`belong_to :user, class_name: "Identity::User"`) этой модели
51
- и ссылаться на неё с помощью внешнего ключа.
52
-
53
- ### Авторизация
54
-
55
- Модель `Identity::User` расширена ролями с помощью
56
- [Rolify](https://github.com/RolifyCommunity/rolify). В частности, у вас есть
57
- говорящие за себя методы:
58
-
59
- ```ruby
60
- user.add_role :manager
61
- user.remove_role :manager
62
- user.has_role? :manager
63
-
64
- Identity::User.with_role :manager
65
- ```
66
-
67
- У вас есть многое другое – смотрите документацию Rolify.
68
-
69
- Используйте эти методы в вызовах вашего авторизационного фреймворка, такого, как
70
- [CanCanCan](https://github.com/CanCanCommunity/cancancan).
71
-
72
42
  ### Админка
73
43
 
74
44
  Чтобы получить админку по пользователям, подключите
@@ -77,19 +47,13 @@ Identity::User.with_role :manager
77
47
 
78
48
  ### Конфигурация
79
49
 
80
- Создайте руби-файл в `config/initializers` со следующим содержимым:
81
-
82
- ```ruby
83
- Identity.setup do |config|
84
- config.devise_modules += [:confirmable]
85
- # и много других конфигурационных опций
86
- end
87
- ```
88
-
89
- #### Доступные опции
50
+ Выполняется в `config/initializers/identity.rb`.
90
51
 
91
52
  Вы всегда можете узнать полный список конфигурацинных опций и их значения по
92
- умолчанию, ознакомившись [с исходным кодом](lib/identity.rb).
53
+ умолчанию, ознакомившись [с исходным кодом](lib/identity.rb). Важные опции:
54
+
55
+ * `config.user_class_name` – имя класса, который будет использоваться, как
56
+ основная модель для аутентификации. По умолчанию: `User`.
93
57
 
94
58
  * `config.devise_modules` – модули Devise, которые вы используете. Например,
95
59
  выключение `registerable` приведёт к невозможности зарегистрироваться, в том
@@ -117,10 +81,6 @@ end
117
81
  * `config.auth_routes` – если задать `false`, маршруты подключены не будут и вы
118
82
  можете сами подключить их.
119
83
 
120
- * `config.admin_role` – "главная" роль в приложении. Роль, которой можно
121
- управлять из предлаемой гемом админки, и роль, которая по умолчанию является
122
- допуском в эту админку.
123
-
124
84
  Вы также можете использовать любые конфигурационные опции самого Devise.
125
85
  Они будут переданы Devise в точности. Например:
126
86
 
@@ -15,7 +15,7 @@ module Identity
15
15
  private
16
16
 
17
17
  def omniauth_login(title)
18
- @user = Identity::User.from_omniauth!(request.env["omniauth.auth"])
18
+ @user = Identity.user_class.from_omniauth!(request.env["omniauth.auth"])
19
19
 
20
20
  set_flash_message(:notice, :success, :kind => title) if is_navigational_format?
21
21
  sign_in_and_redirect @user, :event => :authentication
@@ -1,47 +1,9 @@
1
1
  require "devise"
2
- require "rolify"
3
- require "kaminari"
2
+ require "identity/mixins/user"
4
3
 
5
4
  module Identity
6
5
  class User < ActiveRecord::Base
6
+ include Identity::Mixins::User
7
7
  self.table_name = 'identity_users'
8
- devise *Identity.devise_modules
9
-
10
- if Devise.omniauth_providers.any?
11
- devise :omniauthable, omniauth_providers: Devise.omniauth_providers
12
- end
13
-
14
- rolify role_cname: 'Identity::Role'
15
-
16
- def self.from_omniauth!(auth)
17
- where(provider: auth.provider, uid: auth.uid).first_or_create! do |user|
18
- user.email = auth.provider == "twitter" ? "#{auth.info.nickname}_email@example.com" : auth.info.email
19
- user.password = Devise.friendly_token[0,20]
20
- end
21
- end
22
-
23
- define_singleton_method Identity.admins_method do
24
- with_role(Identity.admin_role)
25
- end
26
-
27
- def self.find_first_by_auth_conditions(tainted_conditions, opts={active: true})
28
- super
29
- end
30
-
31
- def self.active
32
- result = where(active: true)
33
- result = result.where.not(confirmed_at: nil) if devise_modules.include?(:confirmable)
34
- result
35
- end
36
-
37
- def role_names
38
- roles.pluck(:name).sort.join(', ')
39
- end
40
-
41
- define_method Identity.admin_role do
42
- has_role?(Identity.admin_role)
43
- end
44
- alias_method Identity.admin_predicate, Identity.admin_role
45
-
46
8
  end
47
9
  end
@@ -1,5 +1,8 @@
1
1
  Rails.application.routes.draw do
2
2
  if Identity.auth_routes
3
- devise_for :users, class_name: "Identity::User", module: :devise, :controllers => { :omniauth_callbacks => "identity/omniauth_callbacks" }
3
+ devise_for :users,
4
+ class_name: Identity.user_class_name,
5
+ module: :devise,
6
+ controllers: { omniauth_callbacks: "identity/omniauth_callbacks" }
4
7
  end
5
8
  end
@@ -1,6 +1,17 @@
1
- class DeviseCreateIdentityUsers < ActiveRecord::Migration
2
- def change
3
- create_table(:identity_users) do |t|
1
+ require "generators/active_record/devise_generator"
2
+
3
+ module Identity
4
+ class InstallGenerator < ActiveRecord::Generators::DeviseGenerator
5
+ source_root File.expand_path("../templates", __FILE__)
6
+ def config_file
7
+ template "identity.rb", "config/initializers/identity.rb"
8
+ end
9
+
10
+ def inject_devise_content
11
+ end
12
+
13
+ def migration_data
14
+ <<RUBY
4
15
  # To enable/disable users from admin area
5
16
  t.boolean :active, null: false, default: true
6
17
 
@@ -19,8 +30,8 @@ class DeviseCreateIdentityUsers < ActiveRecord::Migration
19
30
  t.integer :sign_in_count, default: 0, null: false
20
31
  t.datetime :current_sign_in_at
21
32
  t.datetime :last_sign_in_at
22
- t.string :current_sign_in_ip
23
- t.string :last_sign_in_ip
33
+ t.#{ip_column} :current_sign_in_ip
34
+ t.#{ip_column} :last_sign_in_ip
24
35
 
25
36
  ## Confirmable
26
37
  t.string :confirmation_token
@@ -31,12 +42,7 @@ class DeviseCreateIdentityUsers < ActiveRecord::Migration
31
42
  ## Omniauthable
32
43
  t.string :provider
33
44
  t.string :uid
34
-
35
- t.timestamps null: true
36
- end
37
-
38
- add_index :identity_users, :email, unique: true
39
- add_index :identity_users, :reset_password_token, unique: true
40
- add_index :identity_users, :confirmation_token, unique: true
45
+ RUBY
46
+ end
41
47
  end
42
48
  end
@@ -0,0 +1,3 @@
1
+ Identity.setup do |config|
2
+ config.user_class_name = "<%= name %>"
3
+ end
@@ -0,0 +1,16 @@
1
+ class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def change
3
+ create_table(:<%= table_name %>) do |t|
4
+ <%= migration_data -%>
5
+ <% attributes.each do |attribute| -%>
6
+ t.<%= attribute.type %> :<%= attribute.name %>
7
+ <% end -%>
8
+
9
+ t.timestamps null: false
10
+ end
11
+ add_index :<%= table_name %>, :email, unique: true
12
+ add_index :<%= table_name %>, :reset_password_token, unique: true
13
+ add_index :<%= table_name %>, :confirmation_token, unique: true
14
+ add_index :<%= table_name %>, [:provider, :uid], unique: true
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ change_table(:<%= table_name %>) do |t|
4
+ <%= migration_data -%>
5
+ <% attributes.each do |attribute| -%>
6
+ t.<%= attribute.type %> :<%= attribute.name %>
7
+ <% end -%>
8
+
9
+ # Uncomment below if timestamps were not included in your original model.
10
+ # t.timestamps null: false
11
+ end
12
+ add_index :<%= table_name %>, :email, unique: true
13
+ add_index :<%= table_name %>, :reset_password_token, unique: true
14
+ add_index :<%= table_name %>, :confirmation_token, unique: true
15
+ add_index :<%= table_name %>, [:provider, :uid], unique: true
16
+ end
17
+
18
+ def self.down
19
+ # By default, we don't want to make any assumption about how to roll back a migration when your
20
+ # model already existed. Please edit below which fields you would like to remove in this migration.
21
+ raise ActiveRecord::IrreversibleMigration
22
+ end
23
+ end
@@ -1,5 +1,4 @@
1
- require "identity/engine"
2
-
1
+ require "devise"
3
2
 
4
3
  module Identity
5
4
  mattr_accessor :devise_modules do
@@ -13,17 +12,12 @@ module Identity
13
12
  ]
14
13
  end
15
14
 
15
+ mattr_accessor(:user_class_name) { "::User" }
16
16
  mattr_accessor(:layout) { 'application' }
17
17
  mattr_accessor(:auth_routes) { true }
18
- mattr_accessor(:admin_namespace) { :identity }
19
- mattr_accessor(:admin_role) { :admin }
20
-
21
- def self.admins_method
22
- :"#{admin_role.to_s.pluralize}"
23
- end
24
18
 
25
- def self.admin_predicate
26
- :"#{admin_role}?"
19
+ def self.user_class
20
+ user_class_name.constantize
27
21
  end
28
22
 
29
23
  def self.setup
@@ -48,3 +42,7 @@ module Identity
48
42
  end
49
43
 
50
44
  end
45
+
46
+ unless caller.find {|s| s.end_with?("`generate_or_destroy'")}
47
+ require "identity/engine"
48
+ end
@@ -1,28 +1,20 @@
1
1
  if defined?(ActiveAdmin)
2
- ActiveAdmin.register Identity::User, as: "Users" do
3
- permit_params :email, :password, :password_confirmation, role_ids: []
2
+ ActiveAdmin.register Identity.user_class, as: "Users" do
3
+ permit_params :email, :password, :password_confirmation
4
4
 
5
5
  filter :email
6
6
  filter :active
7
- filter :roles
8
7
  filter :current_sign_in_at
9
8
  filter :created_at
10
9
 
11
10
  scope :all
12
11
  scope :active, default: true
13
- scope Identity.admins_method
14
12
 
15
13
  index do
16
14
  selectable_column
17
15
  id_column
18
16
  column :active
19
- column Identity.admin_role do |user|
20
- status_tag user.send(Identity.admin_role) ? 'yes' : 'no'
21
- end
22
17
  column :email
23
- column :roles do |user|
24
- user.role_names
25
- end
26
18
  if Devise.mappings[:user].confirmable?
27
19
  column :confirmed do |user|
28
20
  status_tag user.confirmed_at ? 'yes' : 'no'
@@ -42,13 +34,7 @@ if defined?(ActiveAdmin)
42
34
  row :active do |user|
43
35
  status_tag user.active? ? 'yes' : 'no'
44
36
  end
45
- row Identity.admin_role do |user|
46
- status_tag user.send(Identity.admin_role) ? 'yes' : 'no'
47
- end
48
37
  row :email
49
- row :roles do |user|
50
- user.role_names
51
- end
52
38
  if Devise.mappings[:user].trackable?
53
39
  row :sign_in_count
54
40
  row :current_sign_in_ip
@@ -71,7 +57,6 @@ if defined?(ActiveAdmin)
71
57
  input :email
72
58
  input :password
73
59
  input :password_confirmation
74
- input :roles, as: :check_boxes
75
60
  end
76
61
  f.actions
77
62
  end
@@ -1,21 +1,22 @@
1
1
  require "devise"
2
+ require "identity/mixins/user"
2
3
  require_relative "./devise_config"
3
-
4
- require "rolify"
5
-
6
4
  require_relative "./view_helper"
7
5
 
8
- require "kaminari"
9
- Kaminari::Hooks.init
10
-
11
6
  module Identity
12
7
  class Engine < ::Rails::Engine
13
- initializer 'identity-views' do |app|
8
+ initializer "identity-views" do |app|
14
9
  ActionView::Base.include Identity::ViewHelper
15
10
  end
16
11
 
17
- initializer 'identity-admin' do |app|
18
- ActiveAdmin.application.load_paths.unshift(File.dirname(__FILE__) + '/admin')
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)
19
+ end
19
20
  end
20
21
  end
21
22
  end
@@ -0,0 +1,34 @@
1
+ module Identity
2
+ module Mixins
3
+ module User
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ devise *Identity.devise_modules
8
+
9
+ if Devise.omniauth_providers.any?
10
+ devise :omniauthable, omniauth_providers: Devise.omniauth_providers
11
+ end
12
+ end
13
+
14
+ module ClassMethods
15
+ def from_omniauth!(auth)
16
+ where(provider: auth.provider, uid: auth.uid).first_or_create! do |user|
17
+ user.email = auth.provider == "twitter" ? "#{auth.info.nickname}_email@example.com" : auth.info.email
18
+ user.password = Devise.friendly_token[0,20]
19
+ end
20
+ end
21
+
22
+ def find_first_by_auth_conditions(tainted_conditions, opts={active: true})
23
+ super
24
+ end
25
+
26
+ def active
27
+ result = where(active: true)
28
+ result = result.where.not(confirmed_at: nil) if devise_modules.include?(:confirmable)
29
+ result
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module Identity
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anadea-identity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anadea team
@@ -50,26 +50,6 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
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
53
  description: An authentication bootstrapper for your Rails application.
74
54
  email:
75
55
  - dmitriy.kiriyenko@anahoret.com
@@ -85,8 +65,6 @@ files:
85
65
  - app/assets/images/twitter.png
86
66
  - app/controllers/identity/base_controller.rb
87
67
  - app/controllers/identity/omniauth_callbacks_controller.rb
88
- - app/controllers/identity/users_controller.rb
89
- - app/models/identity/role.rb
90
68
  - app/models/identity/user.rb
91
69
  - app/views/devise/confirmations/new.html.erb
92
70
  - app/views/devise/mailer/confirmation_instructions.html.erb
@@ -99,8 +77,6 @@ files:
99
77
  - app/views/devise/sessions/new.html.erb
100
78
  - app/views/devise/shared/_links.erb
101
79
  - app/views/devise/unlocks/new.html.erb
102
- - app/views/identity/users/edit.html.erb
103
- - app/views/identity/users/index.html.erb
104
80
  - config/locales/ca.yml
105
81
  - config/locales/de.yml
106
82
  - config/locales/en.yml
@@ -118,18 +94,20 @@ files:
118
94
  - config/locales/zh-CN.yml
119
95
  - config/locales/zh-TW.yml
120
96
  - config/routes.rb
121
- - db/migrate/20150402142437_devise_create_identity_users.rb
122
- - db/migrate/20150402152859_rolify_create_identity_roles.rb
123
97
  - lib/anadea/identity.rb
98
+ - lib/generators/identity/install_generator.rb
124
99
  - lib/generators/identity/locales_generator.rb
100
+ - lib/generators/identity/templates/identity.rb
101
+ - lib/generators/identity/templates/migration.rb
102
+ - lib/generators/identity/templates/migration_existing.rb
125
103
  - lib/generators/identity/views_generator.rb
126
104
  - lib/identity.rb
127
105
  - lib/identity/admin/user.rb
128
106
  - lib/identity/devise_config.rb
129
107
  - lib/identity/engine.rb
108
+ - lib/identity/mixins/user.rb
130
109
  - lib/identity/version.rb
131
110
  - lib/identity/view_helper.rb
132
- - lib/tasks/whoami_tasks.rake
133
111
  homepage: https://github.com/Anadea/identity
134
112
  licenses:
135
113
  - MIT
@@ -1,58 +0,0 @@
1
- module Identity
2
- class UsersController < ActionController::Base
3
- layout Identity.admin_layout
4
- before_action :ensure_allowed!
5
- helper_method :resource, :resources
6
-
7
- def index
8
- @resources = User.search_and_order(params[:search], params[:page])
9
- end
10
-
11
- def show
12
- redirect_to edit_identity_user_path(params[:id])
13
- end
14
-
15
- def edit
16
- @resource = find_user
17
- end
18
-
19
- def update
20
- @resource = find_user
21
- if @resource.admin_update(user_params, current?(@resource))
22
- @resource.skip_reconfirmation! if @resource.respond_to?(:skip_reconfirmation!)
23
- @resource.save
24
- redirect_to [Identity.admin_namespace, :users], notice: "#{@resource.email} updated."
25
- else
26
- render :edit
27
- end
28
- end
29
-
30
- private
31
-
32
- attr_reader :resource, :resources
33
-
34
- def ensure_allowed!
35
- unless Identity.admin_guard[current_user, self]
36
- raise ActionController::RoutingError.new('Nothing here, move around')
37
- end
38
- end
39
-
40
- def devise_mapping
41
- request.env["devise.mapping"]
42
- end
43
-
44
- def current?(user)
45
- user.id == current_user.id
46
- end
47
-
48
- def find_user
49
- User.find params[:id]
50
- end
51
-
52
- def user_params
53
- params.require(:identity_user).permit(
54
- :email, :password, :password_confirmation, :active, Identity.admin_role
55
- )
56
- end
57
- end
58
- end
@@ -1,16 +0,0 @@
1
- require "rolify"
2
-
3
- module Identity
4
- class Role < ActiveRecord::Base
5
- self.table_name = 'identity_roles'
6
-
7
- has_and_belongs_to_many :users, :join_table => :identity_users_identity_roles
8
- belongs_to :resource, :polymorphic => true
9
-
10
- validates :resource_type,
11
- :inclusion => { :in => Rolify.resource_types },
12
- :allow_nil => true
13
-
14
- scopify
15
- end
16
- end
@@ -1,70 +0,0 @@
1
- <%= content_for(:title) { "Identity: Edit User #{resource.email}" } %>
2
-
3
- <%= bootstrap_devise_error_messages! %>
4
- <div class="row">
5
- <div class="col-sm-6">
6
- <h1>
7
- Edit User <small><%= "#{resource.email} - id: #{resource.id}" %></small>
8
- </h1>
9
- <p><%= link_to "Back to Users", [Identity.admin_namespace, :users] %></p>
10
-
11
- <%= form_for resource,
12
- url: send("#{Identity.admin_namespace}_user_path", resource),
13
- method: :patch,
14
- html: { role: "form" } do |f| %>
15
-
16
- <div class="form-group">
17
- <%= f.label :email %>
18
- <div class="row">
19
- <div class="col-sm-6">
20
- <%= f.email_field :email, class: "form-control" %>
21
- </div>
22
- </div>
23
- </div>
24
-
25
- <div class="form-group">
26
- <%= f.label :password %>
27
- <div class="row">
28
- <div class="col-sm-6">
29
- <%= f.password_field :password, class: "form-control" %>
30
- </div>
31
- </div>
32
- </div>
33
-
34
- <div class="form-group">
35
- <%= f.label :password_confirmation %>
36
- <div class="row">
37
- <div class="col-sm-6">
38
- <%= f.password_field :password_confirmation, class: "form-control" %>
39
- </div>
40
- </div>
41
- </div>
42
-
43
- <% unless current_user.id == resource.id %>
44
- <div class="form-group">
45
- <div class="row">
46
- <div class="col-sm-6">
47
- <%= f.check_box :active %> <%= f.label :active, "Is active?" %>
48
- </div>
49
- </div>
50
- </div>
51
-
52
- <div class="form-group">
53
- <div class="row">
54
- <div class="col-sm-6">
55
- <%= f.check_box Identity.admin_role %> <%= f.label Identity.admin_role, "Is #{Identity.admin_role}?" %>
56
- </div>
57
- </div>
58
- </div>
59
- <% end %>
60
-
61
- <div class="row">
62
- <div class="col-sm-6">
63
- <%= f.submit "Update User", class: "btn btn-danger" %>
64
- </div>
65
- </div>
66
-
67
- <% end %>
68
-
69
- </div>
70
- </div>
@@ -1,55 +0,0 @@
1
- <%= content_for(:title) { "Identity: Users Admin" } %>
2
-
3
- <h1>Users <small>Admin</small></h1>
4
- <p><%= link_to "Back to Application", '/' %></p>
5
-
6
- <div class="text-center">
7
- <p><%= page_entries_info resources %></p>
8
- <%= paginate resources %>
9
- </div>
10
-
11
- <%= form_tag [Identity.admin_namespace, :users], method: 'get', html: {role: "form"} do %>
12
- <p>
13
- <%= text_field_tag :search, params[:search] %>
14
- <%= submit_tag "Search", :name => nil, class: "btn btn-sm btn-primary" %>
15
- <%= link_to "All", [Identity.admin_namespace, :users], {class: "btn btn-sm btn-link"} %>
16
- </p>
17
- <% end %>
18
-
19
- <table class="table table-striped">
20
- <tr>
21
- <th>User ID</th>
22
- <th>Email</th>
23
- <th><%= Identity.admins_method %></th>
24
- <th>Active</th>
25
- <th>Sign In Count</th>
26
- <th>Created At</th>
27
- <th>Last Sign In</th>
28
- <th>Last Sign In IP</th>
29
- </tr>
30
-
31
- <% resources.each do |user| %>
32
-
33
- <tr>
34
- <td><%= user.id %></td>
35
- <td><%= link_to user.email, send("#{Identity.admin_namespace}_user_path", user) %></td>
36
- <td><%= user.send(Identity.admin_predicate) ? "<b>yes</b>".html_safe : "no" %></td>
37
- <td><%= user.active? ? "<b>yes</b>".html_safe : "no" %></td>
38
- <td><%= user.sign_in_count %></td>
39
- <td><%= time_ago_in_words(user.created_at) %></td>
40
- <% unless user.last_sign_in_at.nil? %>
41
- <td><%= time_ago_in_words(user.last_sign_in_at)%> ago</td>
42
- <% else %>
43
- <td>never</td>
44
- <% end %>
45
- <td><%= user.last_sign_in_ip %></td>
46
- </tr>
47
-
48
- <% end %>
49
-
50
- </table>
51
-
52
- <div class="text-center">
53
- <p><%= page_entries_info resources %></p>
54
- <%= paginate resources %>
55
- </div>
@@ -1,19 +0,0 @@
1
- class RolifyCreateIdentityRoles < ActiveRecord::Migration
2
- def change
3
- create_table(:identity_roles) do |t|
4
- t.string :name
5
- t.references :resource, :polymorphic => true
6
-
7
- t.timestamps null: true
8
- end
9
-
10
- create_table(:identity_users_identity_roles, :id => false) do |t|
11
- t.references :user
12
- t.references :role
13
- end
14
-
15
- add_index(:identity_roles, :name)
16
- add_index(:identity_roles, [ :name, :resource_type, :resource_id ])
17
- add_index(:identity_users_identity_roles, [ :user_id, :role_id ])
18
- end
19
- end
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :identity do
3
- # # Task goes here
4
- # end