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')


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

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

Instance Method Details

#can_change_editors?(page) ⇒ Boolean



43
44
45
# File 'app/models/user.rb', line 43

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

#can_edit?(page) ⇒ Boolean



37
38
39
40
41
# File 'app/models/user.rb', line 37

def can_edit?(page)
  self == page.original_author ||
  page.is_open_to_all? ||
  page.editors.split.include?()
end