Class: Droom::DavResource

Inherits:
DAV4Rack::FileResource
  • Object
show all
Defined in:
lib/droom/dav_resource.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(email, password) ⇒ Object



30
31
32
33
# File 'lib/droom/dav_resource.rb', line 30

def authenticate(email, password)
  self.user = User.find_by_email(email)
  user.try(:valid_password?, password)
end

#personObject



22
23
24
# File 'lib/droom/dav_resource.rb', line 22

def person
  user.person
end

#prepareObject

The DAV prefix is a way to evade the callback mechanism. Prepare is only called by our fork of Dav4Rack, at the moment.

Raises:

  • (Dav4Rack::Unauthorized)


16
17
18
19
20
# File 'lib/droom/dav_resource.rb', line 16

def prepare
  raise Dav4Rack::Unauthorized unless person
  FileUtils.mkdir_p(root) unless File.exist?(root)
  person.create_personal_documents if path.blank?  # any request for the root resource
end

#rootObject



26
27
28
# File 'lib/droom/dav_resource.rb', line 26

def root
  Rails.root + "#{Droom.dav_root}/#{person.id}"
end