Module: Sinatra::Security::User

Defined in:
lib/sinatra/security/user.rb

Overview

Mixes in to any included class all of the following:

  • Sinatra::Security::LoginField

  • Sinatra::Security::Password

  • Sinatra::Security::Validations

It also extends the class with Sinatra::Security::Identification.

Examples:


class User < Ohm::Model
  include Sinatra::Security::User
end

user = User.new
user.valid?
user.errors == [[:email, :not_present], [:password, :not_present]]
# => true

user = User.create(:email => "[email protected]", :password => "pass",
                   :password_confirmation => "pass")

User.authenticate("[email protected]", "pass") == user
# => true

Class Method Summary collapse

Class Method Details

.included(user) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/sinatra/security/user.rb', line 29

def self.included(user)
  user.send :include, LoginField
  user.send :include, Password
  user.send :include, Validations

  user.extend Identification 
end