Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Admin functionality in Rails 3

I want to add a admin functionality to my webapp with Rails version 3. I want something very simple, there will be only one admin, this funcionality doesn't need a username field, just a password field. I don't know how to do it, can you help me?

Thanks!

like image 214
rodrigoalvesvieira Avatar asked Feb 26 '23 07:02

rodrigoalvesvieira


1 Answers

Have a look at this Railscast on HTTP simple authentication:

# products_controller.rb
before_filter :authenticate

protected

def authenticate
  authenticate_or_request_with_http_basic do |username, password|
    username == "foo" && password == "bar"
  end
end

As simple as that!

like image 88
Skilldrick Avatar answered Mar 11 '23 22:03

Skilldrick