-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jartek-exclude_devise_modules'.
- Loading branch information
Showing
13 changed files
with
208 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
class <%= user_class %> < ActiveRecord::Base | ||
# Include default devise modules. | ||
devise :database_authenticatable, :registerable, | ||
:recoverable, :rememberable, :trackable, :validatable, | ||
:confirmable, :omniauthable | ||
include DeviseTokenAuth::Concerns::User | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class OnlyEmailUser < ActiveRecord::Base | ||
# Include default devise modules. | ||
devise :database_authenticatable, :registerable | ||
include DeviseTokenAuth::Concerns::User | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration | ||
def change | ||
create_table(:only_email_users) do |t| | ||
## Required | ||
t.string :provider, :null => false | ||
t.string :uid, :null => false, :default => "" | ||
|
||
## Database authenticatable | ||
t.string :encrypted_password, :null => false, :default => "" | ||
|
||
## Recoverable | ||
#t.string :reset_password_token | ||
#t.datetime :reset_password_sent_at | ||
|
||
## Rememberable | ||
#t.datetime :remember_created_at | ||
|
||
## Trackable | ||
#t.integer :sign_in_count, :default => 0, :null => false | ||
#t.datetime :current_sign_in_at | ||
#t.datetime :last_sign_in_at | ||
#t.string :current_sign_in_ip | ||
#t.string :last_sign_in_ip | ||
|
||
## Confirmable | ||
#t.string :confirmation_token | ||
#t.datetime :confirmed_at | ||
#t.datetime :confirmation_sent_at | ||
#t.string :unconfirmed_email # Only if using reconfirmable | ||
|
||
## Lockable | ||
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts | ||
# t.string :unlock_token # Only if unlock strategy is :email or :both | ||
# t.datetime :locked_at | ||
|
||
## User Info | ||
t.string :name | ||
t.string :nickname | ||
t.string :image | ||
t.string :email | ||
|
||
## Tokens | ||
t.text :tokens | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :only_email_users, :email | ||
add_index :only_email_users, [:uid, :provider], :unique => true | ||
#add_index :only_email_users, :reset_password_token, :unique => true | ||
# add_index :only_email_users, :confirmation_token, :unique => true | ||
# add_index :only_email_users, :unlock_token, :unique => true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% timestamp = DateTime.parse(2.weeks.ago.to_s).to_time.strftime("%F %T") %> | ||
<% @email = Faker::Internet.email %> | ||
user: | ||
uid: "<%= @email %>" | ||
email: "<%= @email %>" | ||
provider: 'email' | ||
created_at: '<%= timestamp %>' | ||
updated_at: '<%= timestamp %>' | ||
encrypted_password: <%= User.new.send(:password_digest, 'secret123') %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'test_helper' | ||
|
||
class OnlyEmailUserTest < ActiveSupport::TestCase | ||
describe OnlyEmailUser do | ||
test 'trackable is disabled' do | ||
refute OnlyEmailUser.method_defined?(:sign_in_count) | ||
refute OnlyEmailUser.method_defined?(:current_sign_in_at) | ||
refute OnlyEmailUser.method_defined?(:last_sign_in_at) | ||
refute OnlyEmailUser.method_defined?(:current_sign_in_ip) | ||
refute OnlyEmailUser.method_defined?(:last_sign_in_ip) | ||
end | ||
|
||
test 'confirmable is disabled' do | ||
refute OnlyEmailUser.method_defined?(:confirmation_token) | ||
refute OnlyEmailUser.method_defined?(:confirmed_at) | ||
refute OnlyEmailUser.method_defined?(:confirmation_sent_at) | ||
refute OnlyEmailUser.method_defined?(:unconfirmed_email) | ||
end | ||
|
||
test 'lockable is disabled' do | ||
refute OnlyEmailUser.method_defined?(:failed_attempts) | ||
refute OnlyEmailUser.method_defined?(:unlock_token) | ||
refute OnlyEmailUser.method_defined?(:locked_at) | ||
end | ||
|
||
test 'recoverable is disabled' do | ||
refute OnlyEmailUser.method_defined?(:reset_password_token) | ||
refute OnlyEmailUser.method_defined?(:reset_password_sent_at) | ||
end | ||
|
||
test 'rememberable is disabled' do | ||
refute OnlyEmailUser.method_defined?(:remember_created_at) | ||
end | ||
end | ||
end |