Created
November 10, 2008 22:13
-
-
Save hassox/23659 to your computer and use it in GitHub Desktop.
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 is specifically for you to define your strategies | |
# | |
# You should declare you strategies directly and/or use | |
# Merb::Authentication.activate!(:label_of_strategy) | |
# | |
# To load and set the order of strategy processing | |
Merb::Slices::config[:"merb-auth-slice-password"][:no_default_strategies] = true | |
module Merb::Authentication::Strategies | |
class UserAuthentication < Merb::Authentication::Strategy | |
def run! | |
if params[:username] and params[:password] | |
user = User.auth(params[:username], params[:password]) | |
if !user | |
request.session.authentication.errors.add('username', | |
"Brukernavn og/eller password var feil") | |
end | |
user | |
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
Merb::Plugins.config[:"merb-auth"][:login_param] = :username |
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 is specifically for you to define your strategies | |
# | |
# You should declare you strategies directly and/or use | |
# Merb::Authentication.activate!(:label_of_strategy) | |
# | |
# To load and set the order of strategy processing | |
Merb::Slices::config[:"merb-auth-slice-password"][:no_default_strategies] = true | |
Merb::Authentication.activate!(:default_password_form) | |
module Merb::Authentication::Strategies | |
class Basic::Form < Basic::Base | |
def strategy_error_message | |
"Brukernavn og/eller password var feil" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment