Class: User

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/user.rb

Overview

this model expects a certain database layout and its based on the name/login pattern.

Constant Summary collapse

@@salt =

Please change the salt to something else, Every application should use a different one

'motiro'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authenticate(login, pass) ⇒ Object

Authenticate a user.

Example:

@user = User.authenticate('bob', 'bobpass')


32
33
34
# File 'app/models/user.rb', line 32

def self.authenticate(, pass)
  find(:first, :conditions => ["login = ? AND password = ?", , sha1(pass)])
end

Instance Method Details

#can_change_editors?(page) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/models/user.rb', line 40

def can_change_editors?(page)
  page.original_author.nil? || self == page.original_author
end

#can_edit?(page) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/user.rb', line 36

def can_edit?(page)
  page.editable_by?(self)
end