-
Notifications
You must be signed in to change notification settings - Fork 345
support mongoid aswell #77
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#require 'rails/all' | ||
require 'active_record/connection_adapters/abstract/schema_definitions' | ||
require 'active_record/connection_adapters/abstract/schema_definitions' if defined?(ActiveRecord) | ||
require 'active_support/core_ext/integer' | ||
require 'active_support/ordered_hash' | ||
require 'active_support/concern' | ||
|
@@ -80,6 +80,8 @@ module Controllers | |
end | ||
end | ||
|
||
orm = defined?(Mongoid) ? 'mongoid' : 'active_record' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
# modules | ||
Devise.add_module :password_expirable, :controller => :password_expirable, :model => 'devise_security_extension/models/password_expirable', :route => :password_expired | ||
Devise.add_module :secure_validatable, :model => 'devise_security_extension/models/secure_validatable' | ||
|
@@ -91,6 +93,6 @@ module Controllers | |
# requires | ||
require 'devise_security_extension/routes' | ||
require 'devise_security_extension/rails' | ||
require 'devise_security_extension/orm/active_record' | ||
require 'devise_security_extension/models/old_password' | ||
require 'devise_security_extension/models/security_question' | ||
require 'devise_security_extension/orm/active_record' if defined?(ActiveRecord) | ||
require "devise_security_extension/models/#{orm}/old_password" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this approach to addressing the issue with OldPassword and Mongoid. |
||
require "devise_security_extension/models/#{orm}/security_question" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class OldPassword < ActiveRecord::Base | ||
belongs_to :password_archivable, :polymorphic => true | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
class SecurityQuestion < ActiveRecord::Base | ||
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class OldPassword | ||
include Mongoid::Document | ||
include Mongoid::Timestamps | ||
|
||
field :encrypted_password, :type => String | ||
field :password_salt, :type => String | ||
field :password_archivable_id, :type => Integer | ||
field :password_archivable_type, :type => String | ||
|
||
belongs_to :password_archivable, :polymorphic => true | ||
attr_accessible :encrypted_password | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One comment on this model (and I'm not a Ruby on Rails expert, so take it with a grain of salt but) wouldn't defining |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class SecurityQuestion | ||
include Mongoid::Document | ||
include Mongoid::Timestamps | ||
|
||
field :locale, type: String | ||
field :name, type: String | ||
end |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍