mix-rails-auth 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ class Admix::RolesDatagrid
4
4
  extend AdmixHelper
5
5
 
6
6
  scope do
7
- Role.all
7
+ Role
8
8
  end
9
9
 
10
10
  column :name, header: input_label(:role, :name)
@@ -3,7 +3,7 @@ class Admix::UsersDatagrid
3
3
  include Datagrid
4
4
 
5
5
  scope do
6
- User.desc(:email)
6
+ User
7
7
  end
8
8
 
9
9
  filter :email, :string
data/app/models/role.rb CHANGED
@@ -1,19 +1,6 @@
1
- class Role
2
- include Mongoid::Document
3
-
4
- has_and_belongs_to_many :users
1
+ class Role < ActiveRecord::Base
2
+ has_and_belongs_to_many :users, :join_table => :users_roles
5
3
  belongs_to :resource, :polymorphic => true
6
4
 
7
- field :name, :type => String
8
- index({ :name => 1 }, { :unique => true })
9
-
10
-
11
- index({
12
- :name => 1,
13
- :resource_type => 1,
14
- :resource_id => 1
15
- },
16
- { :unique => true})
17
-
18
5
  scopify
19
6
  end
data/app/models/user.rb CHANGED
@@ -1,52 +1,12 @@
1
- class User
2
- include Mongoid::Document
1
+ class User < ActiveRecord::Base
3
2
  rolify
4
- include Authority::UserAbilities
5
-
6
- ROLES = %w[admin manager]
7
-
8
3
  # Include default devise modules. Others available are:
9
4
  # :token_authenticatable, :confirmable,
10
5
  # :lockable, :timeoutable and :omniauthable
11
- devise :database_authenticatable, :recoverable, :rememberable,
12
- :trackable, :validatable, :registerable
13
-
14
- ## Database authenticatable
15
- field :email, :type => String, :default => ""
16
- field :encrypted_password, :type => String, :default => ""
17
-
18
- validates_presence_of :email
19
- validates_presence_of :encrypted_password
20
-
21
- ## Recoverable
22
- field :reset_password_token, :type => String
23
- field :reset_password_sent_at, :type => Time
24
-
25
- ## Rememberable
26
- field :remember_created_at, :type => Time
27
-
28
- ## Trackable
29
- field :sign_in_count, :type => Integer, :default => 0
30
- field :current_sign_in_at, :type => Time
31
- field :last_sign_in_at, :type => Time
32
- field :current_sign_in_ip, :type => String
33
- field :last_sign_in_ip, :type => String
34
-
35
-
36
- ## Confirmable
37
- # field :confirmation_token, :type => String
38
- # field :confirmed_at, :type => Time
39
- # field :confirmation_sent_at, :type => Time
40
- # field :unconfirmed_email, :type => String # Only if using reconfirmable
41
-
42
- ## Lockable
43
- # field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
44
- # field :unlock_token, :type => String # Only if unlock strategy is :email or :both
45
- # field :locked_at, :type => Time
46
-
47
- ## Token authenticatable
48
- # field :authentication_token, :type => String
49
-
50
- #has_and_belongs_to_many :roles
6
+ devise :database_authenticatable, :registerable,
7
+ :recoverable, :rememberable, :trackable, :validatable
51
8
 
9
+ # Setup accessible (or protected) attributes for your model
10
+ attr_accessible :email, :password, :password_confirmation, :remember_me
11
+ # attr_accessible :title, :body
52
12
  end
@@ -13,7 +13,7 @@ Devise.setup do |config|
13
13
  # Load and configure the ORM. Supports :active_record (default) and
14
14
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
15
15
  # available as additional gems.
16
- require 'devise/orm/mongoid'
16
+ require 'devise/orm/active_record'
17
17
 
18
18
  # ==> Configuration for any authentication mechanism
19
19
  # Configure which keys are used when authenticating a user. The default is
@@ -82,7 +82,7 @@ Devise.setup do |config|
82
82
  config.stretches = Rails.env.test? ? 1 : 10
83
83
 
84
84
  # Setup a pepper to generate the encrypted password.
85
- # config.pepper = "4a428d33a7f2f1d8f58481c17987d070ebcfb5390d1159adff4b1f694f2007c4667ecd6e59fbfc3b7ed30e4fce4b6163fb72b83b778890f26d2d7172a4d9dbff"
85
+ # config.pepper = "5b046673f47fe250ab1561959eee00d884aff9d4e240994d83d0bcc1d6812cfb92a4a8fd6d69f8c00ffa55a03e57b732e0510137b1a585636ccea778ed19df68"
86
86
 
87
87
  # ==> Configuration for :confirmable
88
88
  # A period that the user is allowed to access the website even without
@@ -1,6 +1,6 @@
1
1
  Rolify.configure do |config|
2
2
  # By default ORM adapter is ActiveRecord. uncomment to use mongoid
3
- config.use_mongoid
3
+ # config.use_mongoid
4
4
 
5
5
  # Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
6
6
  # Enable this feature _after_ running rake db:migrate as it relies on the roles table
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Rails.application.routes.draw do
2
-
2
+
3
3
  devise_for :users, sign_out_via: 'get'
4
4
 
5
5
  scope Admix::namespace_path, as: :admix, module: :admix do
@@ -0,0 +1,46 @@
1
+ class DeviseCreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, :null => false, :default => ""
6
+ t.string :encrypted_password, :null => false, :default => ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, :default => 0
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Confirmable
23
+ # t.string :confirmation_token
24
+ # t.datetime :confirmed_at
25
+ # t.datetime :confirmation_sent_at
26
+ # t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
30
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ # t.datetime :locked_at
32
+
33
+ ## Token authenticatable
34
+ # t.string :authentication_token
35
+
36
+
37
+ t.timestamps
38
+ end
39
+
40
+ add_index :users, :email, :unique => true
41
+ add_index :users, :reset_password_token, :unique => true
42
+ # add_index :users, :confirmation_token, :unique => true
43
+ # add_index :users, :unlock_token, :unique => true
44
+ # add_index :users, :authentication_token, :unique => true
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ class RolifyCreateRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table(:roles) do |t|
4
+ t.string :name
5
+ t.references :resource, :polymorphic => true
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ create_table(:users_roles, :id => false) do |t|
11
+ t.references :user
12
+ t.references :role
13
+ end
14
+
15
+ add_index(:roles, :name)
16
+ add_index(:roles, [ :name, :resource_type, :resource_id ])
17
+ add_index(:users_roles, [ :user_id, :role_id ])
18
+ end
19
+ end
@@ -1,5 +1,11 @@
1
1
  module MixRailsAuth
2
2
  class Engine < ::Rails::Engine
3
+
4
+ config.generators do |g|
5
+ g.test_framework :rspec
6
+ g.integration_tool :rspec
7
+ end
8
+
3
9
  def navigation
4
10
  if defined? Admix
5
11
  Admix::Navigation::NavBar.post_menu do
@@ -1,7 +1,7 @@
1
1
  module MixRailsAuth
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 22
4
+ MINOR = 23
5
5
  TINY = 0
6
6
  PRE = nil
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mix-rails-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-06 00:00:00.000000000 Z
13
+ date: 2013-02-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -91,6 +91,8 @@ files:
91
91
  - config/initializers/rolify.rb
92
92
  - config/initializers/devise.rb
93
93
  - config/routes.rb
94
+ - db/migrate/20130206200717_rolify_create_roles.rb
95
+ - db/migrate/20130206200605_devise_create_users.rb
94
96
  - lib/tasks/auth_tasks.rake
95
97
  - lib/mix-rails-auth.rb
96
98
  - lib/mix-rails-auth/version.rb
@@ -112,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
114
  version: '0'
113
115
  segments:
114
116
  - 0
115
- hash: -1563147382618436220
117
+ hash: 443201105873542527
116
118
  required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  none: false
118
120
  requirements:
@@ -121,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  version: '0'
122
124
  segments:
123
125
  - 0
124
- hash: -1563147382618436220
126
+ hash: 443201105873542527
125
127
  requirements: []
126
128
  rubyforge_project:
127
129
  rubygems_version: 1.8.24