Last active
September 5, 2015 05:45
-
-
Save kdwinter/444888 to your computer and use it in GitHub Desktop.
Authlogic plugin for MongoMapper
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
module Authenticable | |
extend ActiveSupport::Concern | |
included do | |
key :username, String | |
key :email, String | |
key :crypted_password, String | |
key :password_salt, String | |
key :persistence_token, String | |
key :login_count, Integer, :default => 0 | |
key :last_request_at, Time | |
key :last_login_at, Time | |
key :current_login_at, Time | |
key :last_login_ip, String | |
key :current_login_ip, String | |
class << self | |
alias named_scope scope | |
end | |
include Authlogic::ActsAsAuthentic::Base | |
include Authlogic::ActsAsAuthentic::Email | |
include Authlogic::ActsAsAuthentic::LoggedInStatus | |
include Authlogic::ActsAsAuthentic::Login | |
include Authlogic::ActsAsAuthentic::MagicColumns | |
include Authlogic::ActsAsAuthentic::Password | |
include Authlogic::ActsAsAuthentic::PerishableToken | |
include Authlogic::ActsAsAuthentic::PersistenceToken | |
include Authlogic::ActsAsAuthentic::RestfulAuthentication | |
include Authlogic::ActsAsAuthentic::SessionMaintenance | |
include Authlogic::ActsAsAuthentic::SingleAccessToken | |
include Authlogic::ActsAsAuthentic::ValidationsScope | |
acts_as_authentic do |c| | |
c.login_field = 'username' | |
c.merge_validates_uniqueness_of_login_field_options :scope => '_id', :case_sensitive => true | |
end | |
end | |
module ClassMethods | |
def base_class | |
self | |
end | |
def primary_key | |
:_id | |
end | |
def default_timezone | |
:utc | |
end | |
def with_scope(qry) | |
qry = where(qry) if qry.is_a?(Hash) | |
yield qry | |
end | |
end | |
module InstanceMethods | |
def save(options = {}) | |
options = {:validate => options} unless options.is_a?(Hash) | |
super | |
end | |
def readonly? | |
false | |
end | |
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
class User | |
include MongoMapper::Document | |
plugin Authenticable | |
timestamps! | |
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
class UserSession < Authlogic::Session::Base | |
def to_key | |
new_record? ? nil : [self.send(self.class.primary_key)] | |
end | |
end |
i getting the following error:
uninitialized constant ActiveSupport::Concern (NameError)
with rails 2.3.11 and mongomapper
I'm getting same error with spockz...
How should i fix that error?
Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting the following error:
With Rails 3.1.3.