Class: Ig3tool::Bitch

Inherits:
ActiveRecord::Base show all
Defined in:
lib/bitching.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveRecord::Base

#attributes_protected_by_default, hash_lookup, set_nonauto_primary_key

Class Method Details

.bitch(crap) ⇒ Object



17
18
19
# File 'lib/bitching.rb', line 17

def self.bitch(crap)
  Bitch.lookup(crap).bitch
end

.can_request?(crap) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/bitching.rb', line 28

def self.can_request?(crap)
	not Bitch.lookup(crap).nil?
end

.lookup(crap) ⇒ Object



13
14
15
# File 'lib/bitching.rb', line 13

def self.lookup(crap)
  Bitch.find(:first, :conditions => ["crap = ?", crap])
end

.wannabe(user, pass) ⇒ Object

Raises:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bitching.rb', line 32

def self.wannabe(user, pass)
  # check if user isa ldap user
  # generate some sort of token to auth with
			raise Token, "you don't know the magic word..." unless IGLDAP.bitchke?(user, pass)
			b = Bitch.new
			b.bitch = user
			#b.crap = user.crypt("$1$" + Time.now.strftime("%S%M"))
			b.crap = Digest::MD5.hexdigest(user + Time.now.to_s)
			b.save!
			b.crap
end

Instance Method Details

#log_request(request) ⇒ Object



21
22
23
24
25
26
# File 'lib/bitching.rb', line 21

def log_request(request)
	r = Request.new
	r.bitch = self.bitch
	r.request = request
	r.save
end