Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made compatible with Merb 1.0 RC1 and added support for merb-auth
- Loading branch information
Showing
7 changed files
with
138 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
scope 'merb-gen' do | ||
Merb.add_generators File.join(File.dirname(__FILE__), 'lib', 'generators', 'model') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Merb::Generators::ModelGenerator.template :model_relaxdb, :orm => :relaxdb do | ||
source(File.dirname(__FILE__), "templates/model/app/models/%file_name%.rb") | ||
destination("app/models", base_path, "#{file_name}.rb") | ||
Merb::Generators::ModelGenerator.template :model_relaxdb, :orm => :relaxdb do |template| | ||
template.source = File.dirname(__FILE__) / "templates/model/app/models/%file_name%.rb" | ||
template.destination = "app/models" / base_path / "#{file_name}.rb" | ||
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,53 @@ | ||
class Merb::Authentication | ||
module Mixins | ||
module SaltedUser | ||
module RDBClassMethods | ||
|
||
def self.extended(base) | ||
base.class_eval do | ||
|
||
property :crypted_password | ||
property :salt | ||
|
||
before_save :password_checks | ||
|
||
def password_checks | ||
if password_required? | ||
return false unless !password.blank? && password == password_confirmation | ||
end | ||
encrypt_password | ||
true | ||
end | ||
|
||
end | ||
end | ||
|
||
def authenticate(login, password) | ||
login_param = Merb::Authentication::Strategies::Basic::Base.login_param | ||
@u = all.sorted_by(login_param) { |q| q.key(login) }.first | ||
@u && @u.authenticated?(password) ? @u : nil | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|
||
class Merb::Authentication | ||
module Mixins | ||
module SaltedUser | ||
|
||
def self.included(base) | ||
base.class_eval do | ||
attr_accessor :password, :password_confirmation | ||
|
||
include Merb::Authentication::Mixins::SaltedUser::InstanceMethods | ||
extend Merb::Authentication::Mixins::SaltedUser::ClassMethods | ||
extend Merb::Authentication::Mixins::SaltedUser::RDBClassMethods | ||
|
||
end | ||
end | ||
|
||
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